Hi to all of stackoverflow, i'm Italian so, i'm sorry for my bad English... :D
i tried to create a simple tableView for listing a few names and a number... all with core data.
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Track *track = [[self fetchedResultsController] objectAtIndexPath:indexPath];
if(YES == self.editing) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Modifica nome" message:@"Prego, inserire di seguito il nuovo nome:" delegate:self cancelButtonTitle:@"Annulla" otherButtonTitles:@"Salva", nil];
newname = [[alert addTextFieldWithValue:track.name label:@"Nome"] text];
[alert textField].autocorrectionType = UITextAutocorrectionTypeNo;
[alert show];
[alert release];
[selectedTrack release];
} else {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Aggiungi minchiate" message:@"Sei sicuro di voler aggiungere una michiata a" delegate:self cancelButtonTitle:@"Annulla" otherButtonTitles:@"Salva", nil];
newname = [[alert addTextFieldWithValue:track.trackAbstract label:@"Minchiate"] text];
[alert textField].autocorrectionType = UITextAutocorrectionTypeNo;
[alert show];
[alert release];
[selectedTrack release];
}
}
I want to send the value of the textfield to my attributes that i've created first... Need I put the code in this method?!
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex != [alertView cancelButtonIndex])
{
//HERE?!
}
}
And how i can set a new value on a core data at开发者_如何学运维tribute? ANY help is appreciated... Thanks in advance!
Yes, you would put the code to grab the value from the text field in the alertView:willDismissWithButtonIndex:
method. Assuming you've created a model class for that entity (which I assume you have, as I see a class called Track
in your code), you can set the value of an attribute by using dot syntax:
Track.someAttribute = newValue
Or without dot syntax, it would be [Track setSomeAttribute:newValue]
.
Also, note that UIAlertView
's addTextFieldWithValue:label:
is an undocumented method, which isn't a problem if this is an app you're planning to create just for yourself, but using it in an app submitted to the App Store will likely get it rejected.
精彩评论