views:

23

answers:

1

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?

+1  A: 

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.

kpower
self.globalDelegate is defined in the header file as such (the entirety is included for clarity) (edit since I can't use pre here, see http://pastebin.com/h6DKyHZJ)That being said, self.globalDelegate shows a value of 0x0 in the debugger -- I suppose I'm not initialising it properly, how would you suggest I do?
roswell
I just realised that my class AppDelegate class is actually named mobilebbAppDelegate... perhaps I should be creating an instance of mobilebbAppDelegate *globalDelegate instead? Trying to do that, however, causes the compiler to throw a few errors...
roswell