У меня есть правильное действие кнопки панели навигации, я установил для него действие, подобное следующему:
-(IBAction)save:(id)sender
{
//Code for saving entered data
UITextField *fieldOne = [self.fields objectAtIndex:0];
UITextField *fieldTwo = [self.fields objectAtIndex:1];
UITextField *fieldThree = [self.fields objectAtIndex:2];
sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &remindersDB) == SQLITE_OK && textField.text != nil)
{
NSString *insertSQL = [NSString stringWithFormat:@"INSERT INTO reminders(name, event, date) VALUES (\"%@\", \"%@\", \"%@\")", fieldOne.text, fieldTwo.text,fieldThree.text];
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(remindersDB, insert_stmt, -1, &statement, NULL);
NSLog(@"%@",fieldOne.text);
NSLog(@"%@",fieldTwo.text);
NSLog(@"%@",fieldThree.text);
if (sqlite3_step(statement) == SQLITE_DONE)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"\n Reminder Saved." message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alert show];
[alert dismissWithClickedButtonIndex:0 animated:YES];
[alert release];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Reminder not saved" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
rowID = sqlite3_last_insert_rowid(remindersDB);
NSLog(@"last inserted rowId = %d",rowID);
sqlite3_finalize(statement);
sqlite3_close(remindersDB);
}
//Alert for not entering any data
if ([textField.text length] == 0)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Fill Data" message:@"Please fill name,event and date of reminder" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
++self.numberOfSaves;
NSLog(@"Number of saves = %d",numberOfSaves);
[self.tableView reloadData];
}
Now I want to check how many times the button is clicked,I have an idea in mind that to create a function and used the condition
-(int)numberOfSaves
{
int saves = 0;
if(self.navigationItem.rightBarButtonItem.enabled==YES)
{
saves++;
}
return saves;
}
Это не работает ......
Есть ли в любом случае, чтобы проверить такое условие, Если так, как я могу его достичь, я новичок в цели-c, пожалуйста, помогите мне ...
Спасибо всем заранее :)