我试图为推送通知添加异步查找,并且我在将launchOptions传递给* @selector
时遇到问题。你能告诉我我需要改变什么吗?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/* Operation Queue init (autorelease) */
NSOperationQueue *queue = [NSOperationQueue new];
/* Create NSInvocationOperation to call loadDataWithOperation, passing in nil */
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(setupPushNotifications) object:launchOptions];
[queue addOperation:operation]; /* Add the operation to the queue */
[operation release];
}
和
-(void)setupPushNotifications:(NSDictionary *)launchOptions
{
//Init Airship launch options
NSMutableDictionary *takeOffOptions = [[[NSMutableDictionary alloc] init] autorelease];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Create Airship singleton that's used to talk to Urban Airship servers.
// Please populate AirshipConfig.plist with your info from http://go.urbanairship.com
[UAirship takeOff:takeOffOptions];
NSLog(@"Registering for Notifications");
// Register for notifications
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
}
答案 0 :(得分:1)
变化
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(setupPushNotifications) object:launchOptions];
到
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(setupPushNotifications:) object:launchOptions];