2014-03-12 250 views
0

我正在使用JSON填充帶標記的mapView。NSJSONSerialization編譯器警告

在方法-(void)connectionDidFinishLoading:(NSURLConnection *)connection

編譯器表示警告:

Incompatible pointer to integer conversion sending 'void *' to parameter of type 'NSJSONReadingOptions' (aka 'enum NSJSONReadingOptions') 

在線路

categorias_first = [NSJSONSerialization JSONObjectWithData:data_for_first_connection options:nil error:nil]; 
categorias_second = [NSJSONSerialization JSONObjectWithData:data_for_second_connection options:nil error:nil]; 
categorias_third = [NSJSONSerialization JSONObjectWithData:data_for_third_connection options:nil error:nil]; 

這是整個方法的代碼:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 
    //if data received network indicator not visible 
    [UIApplication sharedApplication].networkActivityIndicatorVisible=NO; 

    if(connection==first_connection) { 

     categorias_first = [NSJSONSerialization JSONObjectWithData:data_for_first_connection options:nil error:nil]; 

    } 
    else if(connection==second_connection){ 

     categorias_second = [NSJSONSerialization JSONObjectWithData:data_for_second_connection options:nil error:nil]; 
    } 
    else if(connection==third_connection){ 

     categorias_third = [NSJSONSerialization JSONObjectWithData:data_for_third_connection options:nil error:nil]; 
    } 

} 

歡迎任何幫助以避免警告。

+1

通'0',不'nil'爲'options'參數。 – rmaddy

回答

3

nil被視爲((void*)0)並且具有指針類型,但NSJSONReadingOptions(作爲枚舉)是整數類型。

通過options:0

EX更換options:nil

categorias_first = [NSJSONSerialization JSONObjectWithData:data_for_first_connection options:0 error:nil]; 
    ........