ios - tabBarController sending delegate methods to tabs that don't respond to them -



ios - tabBarController sending delegate methods to tabs that don't respond to them -

using storyboard have setup application 3 tab bars. when click on 1 of tabs , have singleton datasource class perform action, , switch tab, when singleton finishes fetching info externally tries send current tab causes crash because current tab on not respond specific delegate method have implemented in singleton delegate, , should not implement since there no reason specific tab perform action. here how delegate setup.

@class dataholder; @protocol dataholdercontrollerdelegate <nsobject> @required -(void)logout; @optional -(void)friendsquarrydidfinishwithdata; -(void)pendingfriendsquarrydidfinishwithdata; -(void)allusersquarrydidfinishwithdata; -(void)additionalfriendsfoundandadded; -(void)messagequarryfinishedwithdata; -(void)thumbnailquarydidfinishwithdata; -(void)sentrequestusersfoundwithdata; @end @interface dataholder : nsobject; @property (nonatomic,weak) id <dataholdercontrollerdelegate>delegate;

the delegate called within method when info queried.

-(void)messagequarry{ pfquery *messagequery = [pfquery querywithclassname:@"message"]; messagequery.cachepolicy = kpfcachepolicycachethennetwork; [messagequery wherekey:@"recipientids" equalto:[[pfuser currentuser] objectid]]; [messagequery wherekey:@"file_type" equalto:@"original_image.png"]; [messagequery findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) { if (error){ nslog(@"error: %@, %@", error, [error userinfo]); }else{ messagesarray = [nsmutablearray arraywitharray:objects]; [delegate messagequarryfinishedwithdata]; } }]; }

than, view controller has delegate method, inboxviewcontroller delegate method called when delegate method above called.

-(void)messagequarryfinishedwithdata{ self.messages = [nsmutablearray arraywitharray:dataholder.getmessages]; [self.tableview reloaddata]; }

remember delegates meant intimate, meaning 1-1 type relationship. seems looking having one-to-many relationship nsnotificationcenter used for. recommend looking nsnotificationcenter documentation form apple.

ios objective-c delegates

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -