Issue Displaying/Hiding Views (Obj-C iPhone Programming)
All right all,
So I've got a UITableView that is inited in applicationDidFinishLaunching
like so:
[self showForumList];
Said method does this:
-(void)showForumList { ForumList *fl = [ForumList alloc]; [fl initWithNibName:@"ForumList" bundle:[NSBundle mainBundle]]; self.ForumList = fl; [window addSubview:[self.ForumList view]]; [fl release]; }where self.ForumList is previously defined in the interface as
ForumList *ForumList;
, etc.
Now, in ForumList
(itself an extension of UITableViewController
obviously), I've got didSelectRowAtIndexPath:
-- within it I have the following code:
Forum *f = [Forum alloc]; NSArray *forums = [f getForumList]; NSDictionary *selectedForum = [forums objectAtIndex:[indexPath row]]; NSString *Url = [selectedForum objectForKey:@"url"]; NSString *Username = [selectedForum objectForKey:@"username"]; NSString *Password = [selectedForum objectForKey:@"password"]; NSLog(@"Identified press on forum %@ (%@/%@)", Url, Username, Password); [self.globalDelegate showForumListFromForumUsingUrl:Url username:Username password:Password]; [self.globalDelegate closeForumList]; NSLog(@"ForumListFromForum init");
Both of the NSLog calls in this function are executed and perform as they should. Now, here is where the issue starts.
self.globalDelegate
is defined as AppDelegate *globalDelegate;
in the Interface specification in my header file. However, [self.globalDelegate showForumListFromForumUsingUrl:username:password]
and and [self.globalDelegate closeForumList]
are never actually called. They look like so:
-(void)closeForumList { NSLog(@"Hiding forum list"); [[self.ForumList view] removeFromSuperview]; } -(void)showForumListFromForumUsingUrl:(NSString *)Url username:(NSString *)Username password:(NSString *)Password { NSLog(@"Showing forum list from forum"); ForumListFromForum *fl = [ForumListFromForum alloc]; [fl initWithNibName:@"ForumListFromForum" bundle:[NSBundle mainBundle]]; [fl initFromForumWithUrl:Url username:Username password:Password]; self.ForumListFromForum = fl;开发者_如何转开发 [window addSubview:[self.ForumListFromForum view]]; [fl release]; }
The app responds to my press, yet neither of these NSLog calls are made, presumably because the calls to the method in appDelegate do not work.
Any idea where I've gone wrong?
I don't see a line, where self.globalDelegate
is allocated & initialized. Maybe, it's the reason.
Moreover, check (in debugger) that in these lines:
[self.globalDelegate showForumListFromForumUsingUrl:Url username:Username password:Password];
[self.globalDelegate closeForumList];
self.globalDelegate is not nil. As you should remember - messages to nil are perceived as correct, but nothing happens.
精彩评论