iOS - Передача LaunchOptions суб-методу - PullRequest
0 голосов
/ 11 декабря 2011

Я пытаюсь добавить асинхронный поиск для Push-уведомлений, и у меня проблема с передачей 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)];
}

1 Ответ

1 голос
/ 11 декабря 2011

изменить

NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(setupPushNotifications) object:launchOptions];

на

NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(setupPushNotifications:) object:launchOptions];
...