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];
        

猜你喜欢

转载自quding0308.iteye.com/blog/1990731