没有报错,是成功以后直接崩溃,提示线程是AVUtil下的某个线程,代码如下
-(void)createCompanyWithCompanyName:(NSString*)comName comId:(NSString*)comId comIndust:(Industry*)indust comRole:(NSString*)role fromCity:(NSString*)city market:(Market*)market legalPerson:(NSString*)legalPersonName legalPersonImage:(UIImage )image creatorRealName:(NSString)realName creatorId:(UIImage*)creatorImage withBlock:(AVBooleanResultBlock)block
{
NSMutableArray* photoFiles=[NSMutableArray array];
NSError* theError;
NSArray* photos=@[image,creatorImage];
for(UIImage* photo in photos){
AVFile* photoFile=[AVFile fileWithData:UIImageJPEGRepresentation(photo, 0.6)];
[photoFile save:&theError];
if(theError==nil){
NSLog(@"上传照片成功");
[photoFiles addObject:photoFile];
}
}
if (theError==nil) {
NSLog(@"成功以后的操作");
AVUser * user=[AVUser currentUser];
Company* company=[Company object];
company.corporation=[photoFiles objectAtIndex:0];
company.legalName=legalPersonName;
company.comName=comName;
company.comId=comId;
company.comIndust=indust;
company.marketRole=role;
company.comCity=city;
company.creator=user;
if (market==nil) {
company.market=[NSArray array];
}
else
{
company.market=@[market];
}
[company saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
NSLog(@"创建公司成功");
//更新用户数据
[self updateUserInfoAfterCreatingCompanyWithUserRealName:realName userIDImage:[photoFiles objectAtIndex:1] company:company withBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
block(YES,nil);
}
else
{
block(NO,error);
}
}];
}
else
{
NSLog(@"创建公司失败");
for (AVFile* uploadedPhoto in photoFiles) {
[uploadedPhoto deleteInBackground];
}
}
}];
}
}
-(void)updateUserInfoAfterCreatingCompanyWithUserRealName:(NSString*)realName userIDImage:(AVFile*)userIDImage company:(Company*)company withBlock:(AVBooleanResultBlock)block;
{
YSUser* user=(YSUser*)[AVUser currentUser];
user.name=realName;
user.company=company;
[user saveInBackgroundWithBlock:block];
}
两个操作都成功了,在数据库中都有显示,但是操作完成以后可以就奔溃了,无报错,是线程错误,奔溃显示之前的截图