У меня возникла ошибка при попытке запустить приложение на моем iPhone. Я не понимаю, почему у меня ошибка нуля в этом случае'NSInvalidArgumentException', причина: '*** setObjectForKey: объект не может быть nil (key: device_uid)'
> Terminating app due to uncaught exception 'NSInvalidArgumentException',<br/>
> reason: ' setObjectForKey: object cannot be nil (key: device_id)'<br/>
> First throw call stack:<br/>
(0x183ce0f48 0x19918bf80 0x183bcc4e0 0x10006f5f0 0x1002b9ca8 0x1002b9c68 0x1002bf710 0x183c981f8 0x183c96060 0x183bc4ca0 0x18f148088 0x1892dcffc 0x1000716a0 0x1999ce8b8)<br/>
libc++abi.dylib: terminating with uncaught exception of type NSException
Here is the part of appdelegate.m file concerned by this error :
// Get the users Device Model, Display Name, Token & Version Number
UIDevice *device = [UIDevice currentDevice];
NSUserDefaults *dict = [NSUserDefaults standardUserDefaults];
NSString *identifier = [dict stringForKey:@"identifier"];
NSString *deviceName = device.name;
NSString *deviceModel = device.model;
NSString *deviceSystemVersion = device.systemVersion;
// Prepare the Device Token for Registration (remove spaces and < >)
NSString *deviceToken = [[[[token description]
stringByReplacingOccurrencesOfString:@"<"withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSMutableDictionary *postDatas = [NSMutableDictionary dictionary];
[postDatas setObject:appName forKey:@"app_name"];
[postDatas setObject:appVersion forKey:@"app_version"];
[postDatas setObject:identifier forKey:@"device_uid"];
[postDatas setObject:deviceToken forKey:@"device_token"];
[postDatas setObject:deviceName forKey:@"device_name"];
[postDatas setObject:deviceModel forKey:@"device_model"];
[postDatas setObject:deviceSystemVersion forKey:@"device_version"];
[postDatas setObject:pushBadge forKey:@"push_badge"];
[postDatas setObject:pushAlert forKey:@"push_alert"];
[postDatas setObject:pushSound forKey:@"push_sound"];
Request *request = [Request alloc];
request.delegate = self;
[request postDatas:postDatas withUrl:@"push/iphone/registerdevice/"];
Этот метод не рекомендуется?
Спасибо за ваш ответ. К сожалению, он не работает, ошибка все еще здесь –
@SiberianScout Какую ошибку вы получаете? –
точно такой же. Вот почему эта ошибка заставляет меня сходить с ума :) –