Проблема с записью NSData на моем устройстве

Может кто-нибудь объяснить мне, почему мой код не работает?

//get the documents directory:
NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];


//make a file name to write the data to using the
//documents directory:
NSString *fullFileName = [NSString stringWithFormat:@"%@/subscriptions", documentsDirectory];
[dataReply writeToFile:fullFileName atomically:NO];




NSData *getData=[[NSData alloc]initWithContentsOfFile:fullFileName];

на самом деле, если я попытаюсь

NSString *string = [[NSString alloc] initWithData:getData encoding:NSASCIIStringEncoding];

в то время как если я загружаю свои данные, не сохраняя их на своем устройстве, это работает! (Поэтому я уверен, что мои данные не пусты)


person paul_1991    schedule 21.09.2011    source источник
comment
определить произведения. определить не работает.   -  person Jean-Denis Muys    schedule 24.09.2011


Ответы (1)


Попробуй это,

NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];


//make a file name to write the data to using the
//documents directory:
NSString *fullFileName = [NSString stringWithFormat:@"%@/subscriptions", documentsDirectory];
[dataReply writeToFile:fullFileName atomically:NO];


Nsdata *getData=[fullFileName dataUsingEncoding:NSUTF8StringEncoding];
person Ravi Chokshi    schedule 21.09.2011