views:

40

answers:

1

HI,

From a table, once i selected the row, i would the row name to be store in a text file. how do i do that?

A: 

Something like this if you wanted to write it to the cache directoy and your using an array to store the information displayed in your table.

   -void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 NSString *SelectedRow = 
  [array objectAtIndex:indexPath.row];
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
   NSString *cachePath = [paths objectAtIndex:0];
   NSString *fileName = [NSString stringWithFormat:@"%@/textfile.txt",                                          cachePath];
[SelectedRow writeToFile:fileName atomically:YES encoding:NSStringEncodingConversionAllowLossy 
                                  error:nil];
 }
octermircty
textfile.txt will be store at? i would to view and make sure its correctly save
iphoneNewbie
can i save it to a property list?
iphoneNewbie
if you swap the .txt for a .plist should save as a plist. And the cache will be in the cache dir in the sim folder on youre mac.
octermircty