Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 40

mishgolf
Aspiring developer
Profile
Posts: 98
Reg: Nov 02, 2012
Sunshine Coast,...
980
03/31/14 04:13 AM (10 years ago)

MessageBar Plugin question

i am adding messagebar plugin to the my favorites plugin(exercise app). I have made it work but have a request, i would like to make the successful message come up when an exercise is added when the + is pressed and turns green, but i also want to make the Error message (red) appear when it is removed by pressing the + again when it turns red. i have added the successful one after [self saveFavorite]; , but it also appears when it is removed, when i want a separate message. Can you please tell me how to do this? i have played around with it with no success. maybe i need to write an else statement? but im no coder. thanks in advance. mishgolf -(void)saveFavorite{ //Options to save to iCloud coming soon [[NSUserDefaults standardUserDefaults] setObject:self.favoriteList forKey:@"screenId"]; [self checkIfFavorite]; NSLog(@"There are %i favorites",[self.favoriteList count]); } -(void)favoriteAdd{ //Appdelegate golffitpro_appDelegate *appDelegate = (golffitpro_appDelegate *)[[UIApplication sharedApplication] delegate]; if([self checkIfFavorite]){ [self.favoriteList removeObject:[appDelegate.rootApp.currentScreenData itemId]]; }else{ [self.favoriteList addObject:[appDelegate.rootApp.currentScreenData itemId]]; } [self saveFavorite]; [MessageBarManager sharedInstance]; [[MessageBarManager sharedInstance] showMessageWithTitle:@"Exercise Added/Removed." description:@"Go to MY PROGRAM to view. Tap to dismiss." type:MessageBarMessageTypeSuccess forDuration:5.0]; } //Checks Current ScreenId against IDs in array. Alters color of basic nav bar button. -(BOOL)checkIfFavorite{ golffitpro_appDelegate *appDelegate = (golffitpro_appDelegate *)[[UIApplication sharedApplication] delegate]; if([self.favoriteList containsObject:[appDelegate.rootApp.currentScreenData itemId]]){ [favoritesAddButton setTintColor:[UIColor greenColor]]; return YES; }else{ [favoritesAddButton setTintColor:[UIColor redColor]]; return NO; } }
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/31/14 05:33 AM (10 years ago)
Add them here if([self checkIfFavorite]){ [self.favoriteList removeObject:[appDelegate.rootApp.currentScreenData itemId]]; [MessageBarManager sharedInstance]; [[MessageBarManager sharedInstance] showMessageWithTitle:@"Exercise Removed." description:@"Go to MY PROGRAM to view. Tap to dismiss." type:MessageBarMessageTypeSuccess forDuration:5.0]; }else{ [self.favoriteList addObject:[appDelegate.rootApp.currentScreenData itemId]]; [MessageBarManager sharedInstance]; [[MessageBarManager sharedInstance] showMessageWithTitle:@"Exercise Added." description:@"Go to MY PROGRAM to view. Tap to dismiss." type:MessageBarMessageTypeSuccess forDuration:5.0]; }
 
mishgolf
Aspiring developer
Profile
Posts: 98
Reg: Nov 02, 2012
Sunshine Coast,...
980
like
03/31/14 09:10 PM (10 years ago)
thanks kittsy il give it go.
 
mishgolf
Aspiring developer
Profile
Posts: 98
Reg: Nov 02, 2012
Sunshine Coast,...
980
like
03/31/14 09:28 PM (10 years ago)
yes that's what i was after thank you it worked.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.