2011-02-08 9 views
10

por lo que obtener este advertencia:cuestión semántica: puntero incompatible a entero conversión enviar 'NSUInteger *' (también conocido como 'unsigned int *') al parámetro de tipo 'NSUInteger'

Semantic Issue: Incompatible pointer to integer conversion sending 'NSUInteger *' (aka 'unsigned int *') to parameter of type 'NSUInteger' (aka 'unsigned int') 

Básicamente estoy tirando en un feed JSON .. bucle a través de las columnas para que coincida con los datos, a continuación, colocar los datos en un objeto para ser utilizado en una fila de la tabla ...

NSDictionary *js_result = [response JSONValue]; 

NSLog(@"This is the LIST: %@",[js_result objectForKey:@"LIST"]); 
// get columns 
NSArray *columns = [[js_result objectForKey:@"LIST"] componentsSeparatedByString:@","]; 
// get data 
NSArray *rows = [[js_result objectForKey:@"QUERY"] objectForKey:@"DATA"]; 



NSUInteger *study_id_int = (NSUInteger *)[columns indexOfObject:@"STUDY_ID_DICOM"]; 
NSUInteger *study_desc_int = (NSUInteger *)[columns indexOfObject:@"STUDY_DESCRIPTION"]; 
NSUInteger *study_date_int = (NSUInteger *)[columns indexOfObject:@"STUDY_DATETIME"]; 
NSUInteger *modality_int = (NSUInteger *)[columns indexOfObject:@"MODALITY"]; 
NSUInteger *referring_physician_name_int = (NSUInteger *)[columns indexOfObject:@"REFERRING_PHYSICIANS_NAME"]; 
NSUInteger *patient_id_dicom_int = (NSUInteger *)[columns indexOfObject:@"PATIENT_ID_DICOM"]; 
NSUInteger *patient_name_int = (NSUInteger *)[columns indexOfObject:@"PATIENT_NAME"]; 
NSUInteger *birth_date_int = (NSUInteger *)[columns indexOfObject:@"BIRTH_DATE"]; 
NSUInteger *institution_name_int = (NSUInteger *)[columns indexOfObject:@"INSTITUTION_NAME"]; 
NSUInteger *study_recvd_datetime_int = (NSUInteger *)[columns indexOfObject:@"STUDY_RECVD_DATETIME"]; 
NSUInteger *image_count_int = (NSUInteger *)[columns indexOfObject:@"Image_Count"]; 
NSUInteger *patient_study_count_int = (NSUInteger *)[columns indexOfObject:@"PATIENT_STUDY_COUNT"]; 



StudyListRow *StudyRow = [[StudyListRow alloc] init]; 

for(NSMutableArray *i in rows) 
{ 
    NSLog(@"ROW DATA: %@",i); 
    StudyListRow *StudyRow = [[StudyListRow alloc] init]; 
    StudyRow.study_id_dicom = (NSString *)[i objectAtIndex:study_id_int]; 
    StudyRow.study_description = [i objectAtIndex:study_desc_int]; 
    StudyRow.study_datetime = [i objectAtIndex:study_date_int]; 
    StudyRow.modality = [i objectAtIndex:modality_int]; 
    StudyRow.referring_physician_name = [i objectAtIndex:referring_physician_name_int]; 
    StudyRow.patient_id_dicom = [i objectAtIndex:patient_id_dicom_int]; 
    StudyRow.patient_name = [i objectAtIndex:patient_name_int]; 
    StudyRow.birth_date = [i objectAtIndex:birth_date_int]; 
    StudyRow.institution_name = [i objectAtIndex:institution_name_int]; 
    StudyRow.study_recvd_datetime = [i objectAtIndex:study_recvd_datetime_int]; 
    StudyRow.image_count = [i objectAtIndex:image_count_int]; 
    StudyRow.patient_study_count = [i objectAtIndex:patient_study_count_int]; 



} 

Cada uno de los StudyRow .... líneas da la advertencia .. y yo hav No tengo idea por qué .. Ideas?

+1

Si realmente lee la advertencia, le dice por qué - "enviando 'NSUInteger *' (también conocido como 'unsigned int *') al parámetro de tipo 'NSUInteger'", es decir, está aprobando punteros en lugar de objetos. – Abizern

+0

Leí la advertencia ... pero soy nuevo en esto ... Lo leí como si enviara un NSUinteger a un NSUinteger ... Ni siquiera noté el * ... – Critter

+0

Aquí está el problema real: recibiste una advertencia pero se inició con la suposición de que hay algo extraño en la advertencia. La suposición inicial debería ser que hay algo mal con el código, y que la advertencia le dirá qué está mal. – gnasher729

Respuesta

22

líneas de este tipo:

NSUInteger *study_id_int = (NSUInteger *)[columns indexOfObject:@"STUDY_ID_DICOM"]; 

debería ser

NSUInteger study_id_int = (NSUInteger)[columns indexOfObject:@"STUDY_ID_DICOM"]; 

Son primitivos, no punteros a objetos (en el que pueda necesitar el asterisco para indicar que solo).

+0

Eso hizo el truco. Gracias. – Critter

+0

@Joseph Tura: ¡Gracias por la edición aclaratoria! – Wevah

+0

Es un placer ... :) –

5

Debe ser NSUInteger varName, no NSUInteger * varName. Ellos son primitivos.

+0

Apagado para leer sobre primitivos ahora ... :) – Critter

Cuestiones relacionadas