我在iPhone模拟器中运行下面的示例代码没有问题,但是当我在iPhone中运行它时,当我调用[asiRequest cancel]时,我总是得到一个EXC_BAD_ACCESS.谁有人可以帮忙?谢谢.
ASIHTTPRequest *asiRequest;
-(IBAction)request1{
NSLog(@"request starting");
[self sendRequest];
}
-(IBAction)cancel1{
NSLog(@"request caceling");
if(asiRequest)
[asiRequest cancel];
}
-(void)sendRequest{
asiRequest=[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://maps.google.com/"]];
[asiRequest setDelegate:self];
[asiRequest startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"requestFinished");
asiRequest=nil;
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSLog(@"request Error=%@",[request error]);
asiRequest=nil;
}
Run Code Online (Sandbox Code Playgroud)
检查api后,我想我不应该在requestFinished或requestFailed中释放它
我怎么能在完成后发布它?
- (void)cancel
{
#if DEBUG_REQUEST_STATUS
NSLog(@"Request cancelled: %@",self);
#endif
[[self cancelledLock] lock];
if ([self isCancelled] || [self complete]) {
[[self cancelledLock] unlock];
return;
}
[self failWithError:ASIRequestCancelledError];
[self setComplete:YES];
[self cancelLoad];
[[self cancelledLock] unlock];
// Must tell …Run Code Online (Sandbox Code Playgroud) 我有一个在Sqlite上使用Core Data的应用程序,现在我有一个更新,它有一些数据库结构更改说添加一个新表
我知道当应用程序更新时,它只更新应用程序二进制文件,文档目录中的任何内容都不会更改.
当应用程序更新并在第一次启动并运行时
[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
Run Code Online (Sandbox Code Playgroud)
它将在Sqlite中找到数据模型和数据库结构之间的差异,并将抛出异常并退出.
错误:"用于打开商店的模型与用于创建商店的模型不兼容"
那么,这里的任何人都可以告诉我如何在数据库结构发生变化时更新应用程序吗?
我认为我们可以在第一次启动更新时运行数据库脚本来创建新表.
但是,如果还有其他更改,例如更改某些字段的类型或删除某些字段,并且我们需要迁移旧数据,这真的很令人头疼.在这种情况下,唯一的方法是创建一个新的应用程序?
有没有人尝试过类似这样的东西?