注册

UserProfileManager.m类,loadUserProfileInBackground: saveToLoacal:completion:报错

你好,我集成EaseUI后,每次点击用户头像,UserProfileManager.m类中的这个函数findObjectsInBackgroundWithBlock语句(第7行)时,都会报错。
错误信息在后面,请大侠指教。
 
 
  1. - (void)loadUserProfileInBackground:(NSArray*)usernames
  2.                        saveToLoacal:(BOOL)save
  3.                          completion:(void (^)(BOOL success, NSError *error))completion
  4. {
  5.     PFQuery *query = [PFQuery queryWithClassName:kPARSE_HXUSER];
  6.     [query whereKey:kPARSE_HXUSER_USERNAME containedIn:usernames];
  7.     [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
  8.         if (!error) {
  9.             for (id user in objects) {
  10.                 if ([user isKindOfClass:[PFObject class]]) {
  11.                     PFObject *pfuser = (PFObject*)user;
  12.                     if (save) {
  13.                         [self savePFUserInDisk:pfuser];
  14.                     } else {
  15.                         [self savePFUserInMemory:pfuser];
  16.                     }
  17.                 }
  18.             }
  19.             if (completion) {
  20.                 completion(YES, nil);
  21.             }
  22.         } else {
  23.             if (completion) {
  24.                 completion(NO, error);
  25.             }
  26.         }
  27.     }];
  28. }

 
错误信息:
2016-04-03 20:25:54.941 SXAgent[7023:137854] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'

*** First throw call stack:

(

    0   CoreFoundation                      0x000000010d21ed85 __exceptionPreprocess + 165

    1   libobjc.A.dylib                     0x000000010c802deb objc_exception_throw + 48

    2   CoreFoundation                      0x000000010d116382 -[__NSDictionaryM setObject:forKey:] + 1042

    3   SXAgent                             0x000000010a2d762b __74-[PFMultiProcessFileLockController beginLockedContentAccessForFileAtPath:]_block_invoke + 129

    4   libdispatch.dylib                   0x000000011065b3eb _dispatch_client_callout + 8

    5   libdispatch.dylib                   0x000000011063fef5 _dispatch_barrier_sync_f_invoke + 393

    6   SXAgent                             0x000000010a2d7585 -[PFMultiProcessFileLockController beginLockedContentAccessForFileAtPath:] + 127

    7   SXAgent                             0x000000010a2f2b12 +[PFObject(Private) _objectFromDataFile:error:] + 203

    8   SXAgent                             0x000000010a331711 +[PFUser(Private) _getCurrentUserWithOptions:] + 611

    9   SXAgent                             0x000000010a30fd80 -[PFQuery _user] + 72

    10  SXAgent                             0x000000010a31118a -[PFQuery _findObjectsAsyncForQueryState:after:] + 171

    11  SXAgent                             0x000000010a310d6b -[PFQuery findObjectsInBackground] + 120

    12  SXAgent                             0x000000010a310f4e -[PFQuery findObjectsInBackgroundWithBlock:] + 445

    13  SXAgent                             0x0000000109d41b52 -[UserProfileManager loadUserProfileInBackground:saveToLoacal:completion:] + 338

    14  SXAgent                             0x0000000109c5ec19 -[UserProfileViewController loadUserProfile] + 553

    15  SXAgent                             0x0000000109c5dcb1 -[UserProfileViewController viewDidLoad] + 705

    16  UIKit                               0x000000010ebe6984 -[UIViewController loadViewIfRequired] + 1198

    17  UIKit                               0x000000010ebec93b -[UIViewController __viewWillAppear:] + 120

    18  UIKit                               0x000000010ec1c750 -[UINavigationController _startCustomTransition:] + 1203

    19  UIKit                               0x000000010ec2cb9b -[UINavigationController _startDeferredTransitionIfNeeded:] + 712

    20  UIKit                               0x000000010ec2dd0b -[UINavigationController __viewWillLayoutSubviews] + 57

    21  UIKit                               0x000000010eddc503 -[UILayoutContainerView layoutSubviews] + 248

    22  UIKit                               0x000000010eb06980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703

    23  QuartzCore                          0x000000010e836c00 -[CALayer layoutSublayers] + 146

    24  QuartzCore                          0x000000010e82b08e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366

    25  QuartzCore                          0x000000010e82af0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24

    26  QuartzCore                          0x000000010e81f3c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277

    27  QuartzCore                          0x000000010e84d086 _ZN2CA11Transaction6commitEv + 486

    28  QuartzCore                          0x000000010e84d7f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92

    29  CoreFoundation                      0x000000010d143c37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23

    30  CoreFoundation                      0x000000010d143ba7 __CFRunLoopDoObservers + 391

    31  CoreFoundation                      0x000000010d1397fb __CFRunLoopRun + 1147

    32  CoreFoundation                      0x000000010d1390f8 CFRunLoopRunSpecific + 488

    33  GraphicsServices                    0x0000000113c89ad2 GSEventRunModal + 161

    34  UIKit                               0x000000010ea4bf09 UIApplicationMain + 171

    35  SXAgent                             0x0000000109dc79e2 main + 114

    36  libdyld.dylib                       0x000000011068f92d start + 1

)
libc++abi.dylib: terminating with uncaught exception of type NSException
已邀请:
头像昵称参考这个文档去实现吧http://community.easemob.com/article/825307675

要回复问题请先登录注册