2016-12-30 2 views
1

Hallo iam neu in Objective C und iosSignal R - erhalten Sie den zweiten Parameter

Ich bin eine Chat-Anwendung Entwicklung mit dieser [Signal R-Bibliothek] [1]

Ich bin in der Lage erfolgreich zu verbinden und rufen ohne irgendein Problem. Aber mein Problem ist, ich abonniere eine Hub-Methode newVisitorNotification Like this.

[chat on:@"newVisitorNotification" perform:self selector:@selector(responsenewVisitorNotification:)];

Wenn eine neue Nachricht an newVisitorNotification kommt, wird er die Daten an responsenewVisitorNotification senden. Diese Methode sendet zwei Parameter

2016-12-30 12:21:52.389411 Chat System[451:79343] CONNECTION: connection did receive data { 
    A =  (
     "6279b7ce-20bf-40f7-b8e8-8f987e209fbf", 
     baman26 
    ); 
    H = ChatHub; 
    M = newVisitorNotification; 
} 

aber meine Methode kann nur ein Parameter erhalten.

-(void) responsenewVisitorNotification:(NSString *) response { 
    NSLog(@"Inside response incomming chat"); 
    NSLog(@"Response incomming Chat : %@", response); 
} 

Kann mir jemand helfen, den zweiten Parameter innerhalb responsenewVisitorNotification zu bekommen.

hier ist mein vollständiger Code

- (void) StartConnection { 

    self.CONNECTIONSTATUS = NO; 
    [self setHubEnvironmentURL]; 
    hubConnection = [SRHubConnection connectionWithURLString:environmentURL]; 
    chat = [hubConnection createHubProxy:@"chatHub"]; 
    [chat on:@"serviceStatus" perform:self selector:@selector(getServiceStaus:)]; 
    [chat on:@"newVisitorNotification" perform:self selector:@selector(responsenewVisitorNotification:)]; 


    // Register for connection lifecycle events 
    [hubConnection setStarted:^{ 
     NSLog(@"Connection Started "); 


     NSLog(@"**************************************************************************"); 
     NSLog(@"****************************** Starting Invoke ***************************"); 
     NSLog(@"**************************************************************************"); 
     [self invokeIncommingChats:ProfileId Company:companyId Token:profileToken]; 

     self.CONNECTIONSTATUS = YES; 
    }]; 
    [hubConnection setReceived:^(NSString *message) { 
     NSLog(@"Connection Recieved Data: %@",message); 
    }]; 
    [hubConnection setConnectionSlow:^{ 
     NSLog(@"Connection Slow"); 
    }]; 
    [hubConnection setReconnecting:^{ 
     NSLog(@"Connection Reconnecting"); 
    }]; 
    [hubConnection setReconnected:^{ 
     NSLog(@"Connection Reconnected"); 
    }]; 
    [hubConnection setClosed:^{ 
     NSLog(@"Connection Closed"); 
    }]; 
    [hubConnection setError:^(NSError *error) { 
     NSLog(@"Connection Error %@",error); 
    }]; 
    // Start the connection 
    [hubConnection start]; 
} 

- (void)getServiceStaus:(NSString *)message { 
    NSLog(@"Service Status : %@", message); 
} 

-(void) responsenewVisitorNotification:(NSString *) response { 
    NSLog(@"Inside response incomming chat"); 
    NSLog(@"Response incomming Chat : %@", response); 
} 


    [1]: https://github.com/DyKnow/SignalR-ObjC 

Antwort

1

Ihre selector ist nicht richtig. Read this.

[chat on:@"newVisitorNotification" perform:self  
//selector:@selector(responsenewVisitorNotification::)] 
selector:@selector(responsenewVisitorNotification:and:)] 

und dann:

-(void) responsenewVisitorNotification:(NSString *) response1 :(NSString*)response2 { 
NSLog(@"Inside response incomming chat"); 
NSLog(@"Response field 1 incomming Chat : %@", response1); 
NSLog(@"Response field 2 incomming Chat : %@", response2); 

} 
Verwandte Themen