您的位置:首页 > 移动开发 > IOS开发

ios后台处理数据存储线程的代码

2012-12-26 20:59 363 查看
在类中,进行编辑下面的代码:
NSLog(@"main thread begin...");
[self
performSelectorInBackground:@selector(doSomething:)
withObject:nil];

NSLog(@"main thread end.....");

- (void) doSomething:(id)sender
{
NSLog(
@"one thread begin..." );

NSAutoreleasePool *pool = [[NSAutoreleasePool
alloc] init];

for (int i=0; i<self.StarName_Final.count;
i++) {

[self
SaveToDataBase:[StarName_Final
objectAtIndex:i]];

}
NSLog(
@"one thread end..." );

[pool
release];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐