读书人

NSString封存到本地读取

发布时间: 2013-12-22 15:06:55 作者: rapoo

NSString保存到本地,读取

保存到本地:

 NSError *error = NULL;        BOOL success = [str writeToFile:document_cache_forum_top atomically:YES encoding:NSUTF8StringEncoding error:&error];        if(!success)        {            NSLog( @"error saving to %@ - %@", document_cache_forum_top, [error localizedDescription] );        }

?

读取str:

NSError *error = NULL;        NSString *str = [NSString stringWithContentsOfFile:document_cache_forum_top encoding:NSUTF8StringEncoding error:&error];        

?

读书人网 >移动开发

热点推荐