When I click "save" I am getting an error when it talks back to the AppDelegate.
I'm sure, that I'm missing something small here, but if anyone has a quick answer it would be greatly appreciated.
Here's the error I'm getting:
-[AppDelegate saveNewUsername:username:]: unrecognized selector sent to instance 0x8e403d0
Here's my button action:
-(IBAction)saveButtonPressed:(id)sender
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *userid = [appDelegate retrieveFromUserDefaults:#"userid"];
NSMutableArray *currentUser = [appDelegate getUserInfo:userid];
NSString *currentUsername = [currentUser objectAtIndex:0];
NSLog(#"%#", userid);
if ([currUsername.text isEqualToString:currentUsername]) {
//here we'll check and make sure the new username is valid and doesn't already exist (for now just update local DB)
if ([theNewUsername.text isEqualToString:#""]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"" message:#"You must enter something for your new username." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
} else {
int returnVal = [appDelegate saveNewUsername:userid username:theNewUsername.text];
if (returnVal == 1) {
[self dismissModalViewControllerAnimated:YES];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"There was an error saving to the database." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
}
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"" message:#"The username you entered is not your current username." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
}
And here's my AppDelegate method:
-(int)saveNewUsername:(NSString *)user_id username:(NSString *)username
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:#"somedbname.sqlite3"];
FMDatabase *db = [FMDatabase databaseWithPath:writableDBPath];
if (![db open]) {
NSLog(#"Could not open db.");
return 0;
} else {
[db intForQuery:#"UPDATE user SET username=? WHERE user_id=?", username, user_id];
if ([db hadError]) {
NSLog(#"Error %d: %#", [db lastErrorCode], [db lastErrorMessage]);
return 0;
} else {
return 1;
}
}
}
Your code looks OK. So I guess appDelegate is actually not an instance of AppDelegate.
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
Set a breakpoint there and have a look in the debugger to check whether it is indeed an instance of AppDelegate.
Related
I'm trying to add a contact to the address book in iOS8. Unable to do so anymore. Here's my code below:
-(void)addPersonToAddressBook {
NSString * fullName = integrationDictionary[#"fullName"];
ABPeoplePickerNavigationController *pp =[ABPeoplePickerNavigationController new];
ABAddressBookRef addressBook = [pp addressBook];
ABRecordRef entry = ABPersonCreate();
CFErrorRef cfError=nil;
ABRecordSetValue(entry, kABPersonFirstNameProperty, (__bridge CFTypeRef)(fullName) , nil);
ABAddressBookAddRecord(addressBook, entry, &cfError);
if (ABAddressBookSave(addressBook, &cfError)) {
NSString *saveMessage = [NSString stringWithFormat:#"%# has been added to your address book.", fullName];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Contact Added" message:saveMessage delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
} else {
NSString *saveMessage = [NSString stringWithFormat:#"There was an error adding %# to your address book.", fullName];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Uh Oh" message:saveMessage delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
NSLog(#"error is %#", cfError);
The error is showing up as null. Has anyone seen this before? Any workarounds?
The error is returning NULL because there's no error registered.
The problem is that [pp addressBook] is returning nil. So your ABAddressBookRef addressBook reference is nil.
The workaround is to use ABAddressBookCreateWithOptions instead of [pp addressBook] method of ABPeoplePickerNavigationController.
Here's a sample which works just fine on both iOS 7.1 & iOS 8.1:
-(void)requestAuthorizationAndAddPersonToAddressBook
{
// Request authorization to Address Book
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
// First time access has been granted, add the contact
[self addPersonToAddressBook];
});
}
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
// The user has previously given access, add the contact
[self addPersonToAddressBook];
}
else {
// The user has previously denied access
// Send an alert telling user to change privacy setting in settings app
}
}
-(void)addPersonToAddressBook {
NSString * fullName = #"James Bond";
CFErrorRef abCreateError = nil;
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &abCreateError);
if (abCreateError) {
NSLog(#"Error occurred: %#", abCreateError);
}
ABRecordRef entry = ABPersonCreate();
CFErrorRef cfError=nil;
ABRecordSetValue(entry, kABPersonFirstNameProperty, (__bridge CFTypeRef)(fullName) , nil);
ABAddressBookAddRecord(addressBook, entry, &cfError);
if (ABAddressBookSave(addressBook, &cfError)) {
NSString *saveMessage = [NSString stringWithFormat:#"%# has been added to your address book.", fullName];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Contact Added" message:saveMessage delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
} else {
NSString *saveMessage = [NSString stringWithFormat:#"There was an error adding %# to your address book.", fullName];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Uh Oh" message:saveMessage delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
if (cfError) {
NSLog(#"error is %#", cfError);
}
}
I am new to Xcode I need an app to send a email. Background: the destination email Id is typed in a text and by clicking the send button the message body Sample should go to the destination Email ID I tried this code in the function button clicked but it is not working when ever i try this code I get error in function can any one guide me with a step by step tutorial
mailTransfer[673:207] delegate - error(-5): timeout sending message
2014-07-05 10:54:05.393 mailTransfer[673:207] * stopping watchdog * I had added the SMTP files from google documents ... any other way to correct this code
- (IBAction)sendMessageInBack:(id)anObject
{
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = #"Yours mail ids";
testMsg.toEmail = emailField.text;
testMsg.relayHost = #"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = #"Your mail ids";
testMsg.pass = #"id password";
testMsg.subject = #"Test application ";
testMsg.wantsSecure = YES;
testMsg.delegate = self;
NSDictionary *plainPart = [NSDictionarydictionaryWithObjectsAndKeys:#"text/plain",kSKPSMTPPartContentTypeKey,#"Sample",kSKPSMTPPartMessageKey,#"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
[testMsg send];
}
-(void)messageSent:(SKPSMTPMessage *)message{
[message release];
NSLog(#"delegate - message sent");
}
-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error{
[message release];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Unable to send email" delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
[alert release];
NSLog(#"delegate - error(%d): %#", [error code], [error localizedDescription]);
}
in SKPSMTPMessage.m
update the following line
CFDictionarySetValue(sslOptions,kCFStreamSSLLevel,kCFStreamSocketSecurityLevelTLSv1);
with
CFDictionarySetValue(sslOptions, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelSSLv3);
Download SMTP framework and import SKPSMTPMessage class..
#import "SKPSMTPMessage.h"
-(void)sendEmailVideo:(NSString*)_toEmailAddress andCC:(NSString*)ccEmail
{
#try
{
// Message =[data getContentOfPanic];
NSData *webData = [NSData dataWithContentsOfURL:videoURL];
SKPSMTPMessage *emailMessage = [[SKPSMTPMessage alloc] init];
emailMessage.fromEmail=#"nikki.varsha#gmail.com";//sender email address
emailMessage.toEmail=_toEmailAddress;
//receiver email address
emailMessage.relayHost=#"smtp.gmail.com";
//emailMessage.ccEmail =ccEmail;
emailMessage.requiresAuth = YES;
emailMessage.login = #"nikki.varsha#gmail.com"; //sender email address
emailMessage.pass = #"123";
//sender email password
emailMessage.subject =#"Panic Video Message";
emailMessage.wantsSecure = YES;
emailMessage.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:#"text/plain",kSKPSMTPPartContentTypeKey,
Message,kSKPSMTPPartMessageKey,#"8bit", kSKPSMTPPartContentTransferEncodingKey,nil];
NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:#"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"Video.mov\"",kSKPSMTPPartContentTypeKey,
#"attachment;\r\n\tfilename=\"Video.mov\"",kSKPSMTPPartContentDispositionKey,[webData encodeBase64ForData],kSKPSMTPPartMessageKey,#"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
emailMessage.parts=[NSArray arrayWithObjects:plainPart,vcfPart,nil];
dispatch_queue_t backgroundVideoQueue = dispatch_queue_create("com.VideoQue", 0);
dispatch_sync(backgroundVideoQueue, ^{
[emailMessage send];
});
}
#catch (NSException *exception)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"No Host" message:#"No Reciever Email Ids Available! " delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alert show];
}
}
pragma mark - sendEmail delegate (SKPSMTPMessage)
-(void)messageSent:(SKPSMTPMessage *)message
{
NSLog(#"delegate - Email sent");
NSLog(#"Mesg %#",message);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Email sent." message:nil delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles: nil];
[alert show];
}
-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error
{
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(#"err=%#" ,message);
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error"
message:#"Unable to send email Please Check EmailId & Password"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[alert show];
});
}
in SKPSMTPMessage.m file do change the following line
Remove this line
//CFDictionarySetValue(sslOptions,kCFStreamSSLLevel,kCFStreamSocketSecurityLevelTLSv1);
Add this line
CFDictionarySetValue(sslOptions, kCFStreamSSLLevel, kCFStreamSocketSecurityLevelSSLv3);
Thanks
I have this code right here for annotations in my map...
//alert view
if ([ann.title isEqual: #"Al-saidiya"]) {
NSString *msg=#"Phone No : 079011111";
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"cancel" otherButtonTitles:#"Call Us", nil];
[alert1 show];
}
else if ([ann.title isEqual: #"Al-Kadmiya"]) {
NSString *msg=#"Phone No : 07902222222";
UIAlertView *alert2 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"ok" otherButtonTitles:#"Call Us", nil];
[alert2 show];
}
else if ([ann.title isEqual: #"Palestine St"]) {
NSString *msg=#"Phone No : 0790333333";
UIAlertView *alert3 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"ok" otherButtonTitles: #"Call Us",nil];
[alert3 show];
}
else if ([ann.title isEqual: #"Karada Maryam"]){
NSString *msg=#"Phone No : 07905867";
UIAlertView *alert4 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"ok" otherButtonTitles:#"Call Us", nil];
[alert4 show];
}
else if ([ann.title isEqual: #"Mansour Office"]) {
NSString *msg=#"Phone No : 07954212";
UIAlertView *alert5 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"ok" otherButtonTitles: #"Call Us",nil];
[alert5 show];
}
else if ([ann.title isEqual: #"Hunting Club"]) {
NSString *msg=#"Phone No : 079337745";
UIAlertView *alert6 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"ok" otherButtonTitles: #"Call Us",nil];
[alert6 show];
}
else if ([ann.title isEqual: #"Al-jadriya"]) {
NSString *msg=#"Phone No : 07976231";
UIAlertView *alert7 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"ok" otherButtonTitles: #"Call Us",nil];
[alert7 show];
}
else if ([ann.title isEqual: #"Al-jamea'a"]) {
NSString *msg=#"Phone No : 07865323";
UIAlertView *alert8 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"ok" otherButtonTitles: #"Call Us",nil];
[alert8 show];
}
}
And when i apply this method ::
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex==1){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"telprompt://576576576"]]];
NSLog(#"It works!");
}
}
it has been applied on every alert objects above there and took the same number.i want every alert object to get its own phone number when i want to call.
Just add a tag to your alert views
if ([ann.title isEqual: #"Al-saidiya"]) {
NSString *msg=#"Phone No : 079011111";
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:#"Contact" message:msg delegate:self cancelButtonTitle:#"cancel" otherButtonTitles:#"Call Us", nil];
alert1.tag = 0; // <--
[alert1 show];
}
and check the tag in alertView:clickedButtonAtIndex::
if (alertView.tag == 0) {
// call Al-saidiya
}
...
Well even if the solution proposed by tilo works, I think is not the right approach when you have multiple instances of objects like UIAlertview.
I would like to suggest you to use blocks instead.
These categories (the project use the same pattern for UIActionSheet) allow you to bind an action block to a specific button in your alertView.
Using this approach you can get rid of all the if/switch statements using the delegate pattern.
As the title and the phone number is a 1:1 relationship I'd use a dictionary:
NSDictionary *titlesAndMessages = #{#"Al-saidiya" : #"Phone No : 079011111",
#"Al-Kadmiya" : #"Phone No : 07902222222",
#"Palestine St" : #"Phone No : 0790333333"};
...
NSString *messageString = nil;
for (NSString *keyTitle in [titlesAndMessages allKeys]) {
if ([ann.title isEqualToString:keyTitle]) {
messageString = [titlesAndMessages objectForKey:keyTitle];
break;
}
}
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Contact" message:messageString delegate:self cancelButtonTitle:#"ok" otherButtonTitles:#"Call Us", nil];
[alert show];
}
This scales a lot better as you won't have to write any additional code to expand, just add entries to the dictionary (automagically or otherwise).
Using UIAlertViewDelegate is really clumsy. I recommend everyone use PSAlertView for any non-trivial use of alerts.
Using this, the code becomes simple and self contained.
- (void)promptToContact:(NSString *)message
withNumber:(NSString *)phoneNumber
{
PSAlertView *alert = [[PSAlertView alloc] initWithTitle:#"Contact"];
[alert setCancelButtonWithTitle:#"Dismiss" block:^{}];
[alert addButtonWithTitle:#"Call" block:^{
NSString *urlString = [NSString stringWithFormat:#"telprompt://%#", phoneNumber];
NSURL *url = [NSURL urlWithString:urlString];
[[UIApplication sharedApplication] openURL:url];
}];
[alert show];
}
First set the tag in your alertview in above code then in your below method. Try like this:-
-(void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
int indexValue=alertView.tag;
switch (indexValue)
{
case 0:
NSLog (#"zero");
//your code
break;
case 1:
NSLog (#"one");
//your code
break;
case 2:
NSLog (#"two");
//your code
break;
case 3:
NSLog (#"three");
// your code
break;
case 4:
NSLog (#"four");
//your code
break;
case 5:
NSLog (#"five");
// your code
break;
...... Up to
case 8:
// your code
break;
default:
NSLog (#"done");
break;
}
I'm having trouble with my app. Problem is when I press the Cancel button on the AlertView. It doesn't show the "Cancel" text that should be appearing at my output. The Confirm and Show Password buttons are working fine, both show the NSLogs, only the cancel buttons don't. Here is my code. Please be patient with me because I'm new in Xcode.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:#"Confirm"])
{
UITextField *password = [alertView textFieldAtIndex:0];
NSLog(#"Password: %#", password.text);
if (buttonIndex != [alertView cancelButtonIndex])
{
NSLog(#"cancel");
}
else
{
NSLog(#"confirm");
entries = [[NSMutableArray alloc]init];
NSString *select = [NSString stringWithFormat:#"SELECT * FROM summary2 WHERE username = '%s' and pass = '%s'",[self.lbUser.text UTF8String],[password.text UTF8String]];
sqlite3_stmt *statement;
if (sqlite3_prepare(user, [select UTF8String], -1, &statement, nil)==SQLITE_OK)
{
if(sqlite3_step(statement)==SQLITE_ROW)
{
NSLog(#"database updated");
[self updatedatabase];
UIAlertView *alert3 = [[UIAlertView alloc]initWithTitle:#"Done" message:#"Account was updated successfully!" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert3 show];
}
else
{
NSLog(#"Authentication Failed!");
UIAlertView *alert2 = [[UIAlertView alloc]initWithTitle:#"Failed" message:#"Wrong Password! Account was not updated." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert2 show];
NSLog(#"fail");
}
}
}
}
else if([title isEqualToString:#"View Password"])
{
UITextField *password = [alertView textFieldAtIndex:0];
NSLog(#"Password: %#", password.text);
if (buttonIndex != [alertView cancelButtonIndex])
{
NSLog(#"cancel");
}
else
{
NSLog(#"confirm");
entries = [[NSMutableArray alloc]init];
NSString *select = [NSString stringWithFormat:#"SELECT * FROM summary2 WHERE username = '%s' and pass = '%s'",[self.lbUser.text UTF8String],[password.text UTF8String]];
sqlite3_stmt *statement;
if (sqlite3_prepare(user, [select UTF8String], -1, &statement, nil)==SQLITE_OK)
{
if(sqlite3_step(statement)==SQLITE_ROW)
{
NSLog(#"database updated");
[self switchbtn];
}
else
{
//switch1.on=YES;
NSLog(#"Authentication Failed!");
UIAlertView *alert2 = [[UIAlertView alloc]initWithTitle:#"Failed" message:#"Wrong Password! Cannot view password." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert2 show];
NSLog(#"fail");
}
}
}
}
}
According to your if,if-else statements you're only looking for "View Password" and "Confirm" buttons. There is no branch in your if-statement to examine the cancel button.
Every time I try to save my NSManagedObjectContex, it takes 1-8 seconds each time. Here is my code:
- (IBAction)save
{
if (self.managedObjectContext == nil) {
self.managedObjectContext = [(RootAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
}
if (self.brandText.text.length == 0 || self.modelText.text.length == 0) {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:#"Error" message:#"Please fill out the required fields" delegate:self cancelButtonTitle:#"Dismiss" otherButtonTitles:nil, nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(125, 40, 31, 7)];
NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:#"bullet.png"]];
UIImage *bkgImg = [[UIImage alloc] initWithContentsOfFile:path];
[imageView setImage:bkgImg];
[alertView addSubview:imageView];
[alertView show];
} else {
Hand *a = [NSEntityDescription insertNewObjectForEntityForName:#"Hand" inManagedObjectContext:self.managedObjectContext];
a.brand = self.brandText.text;
a.caliber = self.cText.text;
self.managedObjectContext = self.app.managedObjectContext;
a.notes = self.notesView.text;
a.serialNumber = self.serialNumberText.text;
a.nickname = self.nicknameText.text;
a.model = self.modelText.text;
a.gunImage = self.image.image;
a.roundsFired = [NSString stringWithFormat:#"0"];
a.cleanRounds = [NSString stringWithFormat:#"500"];
a.showBadge = [NSNumber numberWithBool:YES];
[self dismissViewControllerAnimated:YES completion:nil];
NSError *error;
if (![self.managedObjectContext save:&error]) {
UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:#"Error" message:#"There was an internal error. \n Please restart the app and try again, Thank You" delegate:self cancelButtonTitle:#"Dismiss" otherButtonTitles:nil, nil];
[errorAlert show];
}
}
}
The code just saves the all of the textFields text. What is the reason its so slow? Any help is greatly appreciated.
Based on your question is quite difficult to understand what is going on but I would modify the else statement as follows...
else {
Hand *a = [NSEntityDescription insertNewObjectForEntityForName:#"Hand" inManagedObjectContext:self.managedObjectContext];
a.brand = self.brandText.text;
a.caliber = self.cText.text;
// why this?
// self.managedObjectContext = self.app.managedObjectContext;
a.notes = self.notesView.text;
a.serialNumber = self.serialNumberText.text;
a.nickname = self.nicknameText.text;
a.model = self.modelText.text;
a.gunImage = self.image.image;
a.roundsFired = [NSString stringWithFormat:#"0"];
a.cleanRounds = [NSString stringWithFormat:#"500"];
a.showBadge = [NSNumber numberWithBool:YES];
NSError *error;
if (![self.managedObjectContext save:&error]) { // error during saving
UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:#"Error" message:#"There was an internal error. \n Please restart the app and try again, Thank You" delegate:self cancelButtonTitle:#"Dismiss" otherButtonTitles:nil, nil];
[errorAlert show];
} else { // the save completes correctly, dismiss the view controller
[self dismissViewControllerAnimated:YES completion:nil];
}
}
If you want to monitor Core Data you should do it through Instrument. In addition you could set up Xcode as follows: XCode4 and Core Data: How to enable SQL Debugging.
Edit
Since the slow saving is due (based on your comment) to images, you should relies on these rules.
Core Data - Storing Images (iPhone)
Edit 2
Ok, since you don't know in advance about the size (in bytes) of your image, I really suggest to store the image in the filesystem and not in the Core Data store. In the db save only the path to your image. The image will be saved in background. This to prevent the UI to block.
Otherwise, if iOS 5 is the minimum requirement, use the External Storage flag.
How to enable External Storage for Binary Data in Core Data
Hope that helps.