gpt4 book ai didi

ios - 将对象添加到 Parse.com 类时出现异常

转载 作者:行者123 更新时间:2023-11-28 22:09:26 24 4
gpt4 key购买 nike

我在创建记录并将记录发送到 Parse 时遇到以下异常,我想知道是否有人可以阐明它,或者如何寻找解决方案..

2014-04-23 22:38:19.397 DreamCatching[10731:303] Can't use nil for keys or values on PFObject. Use NSNull for values.
2014-04-23 22:38:19.399 DreamCatching[10731:303] (
0 CoreFoundation 0x00007fff8933a25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff89827e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8933a10c +[NSException raise:format:] + 204
3 ParseOSX 0x00000001000cc9ac -[PFObject setObject:forKey:] + 69
4 DreamCatching 0x000000010000681f -[DreamViewController endPlaces:] + 975
5 AppKit 0x00007fff8dfbd260 -[NSApplication sendAction:to:from:] + 327
6 AppKit 0x00007fff8dfbd0de -[NSControl sendAction:to:] + 86
7 AppKit 0x00007fff8e009c4d -[NSCell _sendActionFrom:] + 128
8 AppKit 0x00007fff8e023655 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2316
9 AppKit 0x00007fff8e022a27 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 487
10 AppKit 0x00007fff8e02213d -[NSControl mouseDown:] + 706
11 AppKit 0x00007fff8dfa3a58 -[NSWindow sendEvent:] + 11296
12 AppKit 0x00007fff8df425d4 -[NSApplication sendEvent:] + 2021
13 AppKit 0x00007fff8dd92a19 -[NSApplication run] + 646
14 AppKit 0x00007fff8dd7d7a3 NSApplicationMain + 940
15 DreamCatching 0x000000010001a862 main + 34
16 libdyld.dylib 0x00007fff886a45fd start + 1
17 ??? 0x0000000000000003 0x0 + 3
)

我发送的记录看起来像这样(在崩溃之前记录):

2014-04-23 22:38:19.397 DreamCatching[10731:303] endPlaces: newJoin: <DDPlaceJoin:new:(null)> {
ACL = "<PFACL: 0x6100002574f0>";
mainKey = 070213681717;
mainName = "About Time";
parseUser = "<PFUser:BJdxGyXnkn>";
placeKey = 042314094048;
placeName = London;
}

Parse 对象中没有其他用户元素。这也只是偶尔发生,尽管很频繁。

我的代码如下:

- (IBAction)endPlaces:(id)sender {
NSLog(@"%s", __FUNCTION__);
//selectedPlaces should be in its final state.
//use it to rebuild the placesJoin class

[self endSheet:self.sheet returnCode:result];

//rebuild Places Join array and save it. The replacement info is in selectedPlaces

//1. empty the current join array for this dream

[self clearPlaceJoins];

[PFQuery clearAllCachedResults];

// 2. Build new join table based on selectedPlaces

//NSLog(@"There are some Places noted in this dream");
NSLog(@"endPlaces: selectedPlaces is %@", selectedPlaces);
NSLog(@"endPlaces: selectedPlaces Count is %lu", (unsigned long)selectedPlaces.count);

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

PFObject *newJoin = [PFObject objectWithClassName:@"DDPlaceJoin"];
NSString *tempDreamKey = [selectedPlaces[i] valueForKey:@"mainKey"];
NSString *tempPlaceKey = [selectedPlaces[i] valueForKey:@"placeKey"];
NSString *tempDreamName = [selectedPlaces[i] valueForKey:@"mainName"];
NSString *tempPlaceName = [selectedPlaces[i] valueForKey:@"placeName"];

[newJoin setObject:tempDreamKey forKey:@"mainKey"];
[newJoin setObject:tempPlaceKey forKey:@"placeKey"];
[newJoin setObject:tempDreamName forKey:@"mainName"];
[newJoin setObject:tempPlaceName forKey:@"placeName"];
[newJoin setObject:[PFUser currentUser] forKey:@"parseUser"];

query.cachePolicy = kPFCachePolicyNetworkElseCache;

//Set ACL permissions for added security
PFACL *joinACL = [PFACL ACLWithUser:[PFUser currentUser]];
[newJoin setACL:joinACL];

NSLog(@"endPlaces: newJoin: %@", newJoin);

[newJoin saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
// Revert state on save error.
NSLog(@"Error saving a placejoin");
}
}];

}

}

感谢您的帮助。

最佳答案

崩溃发生在对 setObject:forKey: 的调用之一中,这意味着您的 NSLog 发生在崩溃之后。您可能看到的是最后一条有效的记录,而不是导致问题的记录。

尝试在第一个 setObject:forKey: 之前放置一个断点或 NSLog,并确保所有 temp* 值都不是 nil。如果有任何一个是 nil 并且它们永远不应该是,您可能想找出原因。否则,您应该确保在将它们添加到您的 PFObject 之前注意这些值并将它们更改为 [NSNull null]

关于ios - 将对象添加到 Parse.com 类时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23253864/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com