我有一个NSMutableArray
self.certificates
该数组由保存的字符串和核心数据组成。我想通过 AirDrop 发送这个。我已经检查过了serialization
,我正在尝试用以下方式发送它
- (void)send{
NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:self.certificates options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
NSLog(@"Electrical Certificates List:\n%@", jsonString);
UIActivityViewController *activityCtr = [[UIActivityViewController alloc] initWithActivityItems:@[jsonString]
applicationActivities:nil];
NSMutableArray *excludedActivities = [self iOSActivities].mutableCopy;
[excludedActivities addObject:UIActivityTypeAddToReadingList];
[excludedActivities addObject:UIActivityTypePostToFlickr];
[excludedActivities addObject:UIActivityTypePostToTencentWeibo];
[excludedActivities addObject:UIActivityTypePostToVimeo];
[activityCtr setExcludedActivityTypes:excludedActivities];
[self presentViewController:activityCtr
animated:YES
completion:nil];
}
这给了我以下错误
'NSInvalidArgumentException', reason: 'Invalid type in JSON write (Certificate)'
我已将数据转换为字符串,所以不确定我在这里缺少什么
我研究了 NSInvalidArgumentException,原因:“JSON 写入 (__NSDate) 中的类型无效”以及如何将 NSArray 发送到 Web 服务