ココアプロジェクトのプログレスバーとしてMBProgressHUDまたはZAActivityBarを使用しようとしています。すべて問題ありませんが、ある場所では、このプログレスバービューはシングルトンクラスから機能を実行した後にのみ表示されますが、実行中のはずです。
-(IBAction)importButtonClicked:(id)sender
{
//[ZAActivityBar showSyncWithStatus:NSLocalizedString(@"MBProgressHUDLabel", nil) forAction:@"importButtonClicked"];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
int count=0;
count=[[CoreDataHelper helperCoreDataHelper] saveImportedFriends:_importedFriendsDictionary withOnlyDate:_onlyDateSwitcher withRewrite:(int)_rewriteSwitcher];
//[ZAActivityBar dismissSyncForAction:@"importButtonClicked"];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
CoreDataHelper.m
-(int)saveImportedFriends:(NSMutableSet*)set withOnlyDate:(int)withDate withRewrite:(int)rewrite
{
int count=0;
for(FriendsForImport* friendsForImport in set)
{
if((withDate==1 && friendsForImport.birthday.length>0) || withDate==0)
{
Friends *friendsExist=[self checkFriendAlreadyExist:friendsForImport];
if((friendsExist.lastName.length>0 || friendsExist.firstName.length>0) && rewrite==0)
continue;
else if((friendsExist.lastName.length>0 || friendsExist.firstName.length>0) && rewrite==1)
[self deleteFriendAlreadyExist:friendsExist];
UIImage *image;
if([friendsForImport.importFrom intValue]==1)
{
image = [[UIImageHelper helper] getUIImageFromAddressBookContactId:[friendsForImport.uid integerValue]];
}
else
image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:friendsForImport.photoPath]]];
NSString *imageName=@"";
if(image.size.height>0)
imageName=[[UIImageHelper helper] saveImage:[[UIImageHelper helper] resizedImage:image withRect:CGRectMake(0, 0, kAvatarSize, kAvatarSize)]];
Friends *friends= (Friends *)[NSEntityDescription insertNewObjectForEntityForName:@"Friends" inManagedObjectContext:_managedObjectContext];
friends.lastName=friendsForImport.lastName;
friends.firstName=friendsForImport.firstName;
friends.uid=[NSString stringWithFormat:@"%@",friendsForImport.uid];
friends.birthday=[[CoreDataHelper helperCoreDataHelper] properDateString:friendsForImport.birthday];
friends.alarm=[NSNumber numberWithInt:1];
friends.important=NO;
friends.photoPath=imageName;
friends.importFrom=friendsForImport.importFrom;
friends.importDate=[NSDate date];
//NSLog(@"friends %@",friends);
NSError *error = nil;
if (![_managedObjectContext save:&error]) {
NSLog(@"Error in adding a new bank %@, %@", error, [error userInfo]);
abort();
}
count++;
}
}
return count;
}