お気に入りのお気に入りを完璧に機能させる機能を開発しようとしていますが、次または前のボタンを押すとクラッシュします...
現在のメッセージが FavouriteArray に存在することを確認する方法がわかりません..? 存在する場合 FavouriteButton 画像 Favourite-ON.png に変更それ以外の場合はその画像 Favourite-OFF.png ..
私のコードは以下です==================
// Adding Current Message to Favourite Array
- (IBAction)FavouritebtnClick:(id)sender //Favourite Button Work Perfectly
{
Make_Fav_Text = [NSString stringWithFormat:@"%@",[[[TabBarTutorialAppDelegate shareDelegate].level_array valueForKey:@"SMS"] objectAtIndex:row_no]];
NSLog(@"Make Favourite TExt====%@",Make_Fav_Text);
[DatabaseFiles InsertFav:[NSString stringWithFormat:@"%@",Make_Fav_Text]];//insert to database
[FavouriteBtnChange setImage:[UIImage imageNamed:@"FAv_On-iphone.png"] forState:UIControlStateNormal];
}
// FavouriteArray で現在のメッセージが利用可能であることを確認します
-(void)Check_Fav_Available
{
for (NSString *Myfav in Check_Fav_Avail)
{
NSLog(@"MYFAV===%@",Myfav);
if ([Myfav isEqual:sms.text])
{
[FavouriteBtnChange setImage:[UIImage imageNamed:@"FAv_On-iphone.png"] forState:UIControlStateNormal];
NSLog(@"Found Favourite");
//break;
}
else{
NSLog(@"NOt Found");
[FavouriteBtnChange setImage:[UIImage imageNamed:@"FAv_On-copy-iphone"] forState:UIControlStateNormal];
}
}
}
//Next Button
- (IBAction)Nextbtn:(id)sender
{
row_no=row_no+1;
lblno=row_no;
lblno=lblno+1;
[self Check_Fav_Available]; //Check Current Message in Favourite Array;
if (row_no==[TabBarTutorialAppDelegate shareDelegate].level_array.count)
{
row_no=row_no-1;
// lblno=lblno-1;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"This is last SMS" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
NSLog(@"this is last");
NSLog(@"row no is %d",row_no);
}
else
{
if (row_no <=4)
{
sms.text=[[[TabBarTutorialAppDelegate shareDelegate].level_array objectAtIndex:row_no] objectForKey:@"SMS"];
NSString *str = [NSString stringWithFormat:@"%d - %d",lblno,[TabBarTutorialAppDelegate shareDelegate].level_array.count];
no_lbl.text=str;
NSLog(@"row no is %d",row_no);
[self Check_Fav_Available];
}
else
{
UIAlertView *Purchasealert = [[UIAlertView alloc] initWithTitle:@"Purchase Category" message:@"Purchase to Enjoy More" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Buy Message", nil];
Purchasealert.tag=1710;
[Purchasealert show];
[self gostore];
NSLog(@"this is last");
NSLog(@"row no is %d",row_no);
}
}
}
//Previous Button
- (IBAction)Previousbtn:(id)sender
{
//[FavouriteBtnChange setImage:[UIImage imageNamed:@"FAv_On-copy-iphone.png"] forState:UIControlStateNormal];
row_no=row_no-1;
lblno=lblno-1;
if (row_no<0)
{
row_no=row_no+1;
lblno=lblno+1;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"This is First SMS" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
NSLog(@"this is last");
}
else
{
[self Check_Fav_Available]; //Check Favourite available
sms.text=[[[TabBarTutorialAppDelegate shareDelegate].level_array objectAtIndex:row_no] objectForKey:@"SMS"];
NSString *str = [NSString stringWithFormat:@"%d - %d",lblno,[TabBarTutorialAppDelegate shareDelegate].level_array.count];
no_lbl.text=str;
[self Check_Fav_Available];
NSLog(@"arr is %d",[TabBarTutorialAppDelegate shareDelegate].level_array.count);
NSLog(@"row no is %d",row_no);
}
}