Hello there! I'm tryin to use some code to create a badge number for the iPhone App Icon.
I can successfully do this, however the code I am using (below) is pretty bad and could easily be done better, however I do not have the logic knowledge to be able to do this.
This is what it's doing...
- Get's the 'ID' of a user from the first message in a UITableView. It then checks this against the stored ID (from the first object when it was last loaded) and makes the badge number 1.
- Then checks the second ID in a message to see if that is the same as the stored. If not it will make the badge number 2.
- etc etc..
What I want it to do is automatically check the IDs and add '1' to the badge number until the first post with the correct ID is found however, I'm not too sure on the coding.
Any help would be great!
Thanks
(The code is below:)
NSDictionary* tweetValues = [[NSDictionary alloc] init];
tweetValues = [tweets objectAtIndex:1];
NSString *newStatusID = [[tweetValues objectForKey:@"id"] stringValue];
NSString *oldStatusID = [[NSUserDefaults standardUserDefaults] stringForKey:@"latestID"];
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
if([newStatusID isEqualToString:oldStatusID]){
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
} else {
tweetValues = [tweets objectAtIndex:2];
newStatusID = [[tweetValues objectForKey:@"id"] stringValue];
if ([newStatusID isEqualToString:oldStatusID]){
[UIApplication sharedApplication].applicationIconBadgeNumber = 1;
}else{
tweetValues = [tweets objectAtIndex:3];
newStatusID = [[tweetValues objectForKey:@"id"] stringValue];
if ([newStatusID isEqualToString:oldStatusID]){
[UIApplication sharedApplication].applicationIconBadgeNumber = 2;
}else{
[UIApplication sharedApplication].applicationIconBadgeNumber = 3;
}
}
}