语义问题:指向整数转换的指针不兼容,将'NSUInteger *'(又名'unsigned int *')发送到'NSUInteger'类型的参数

时间:2011-02-08 20:53:21

标签: iphone objective-c ipad ios4 nsarray

所以我得到了警告

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

基本上我正在使用JSON提要..循环遍历它以使列与数据匹配,然后将数据放在要在表格行中使用的对象中...

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];



}

每个 StudyRow .... 行都会发出警告..我不明白为什么......想法?

2 个答案:

答案 0 :(得分:22)

这样的行:

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

应该是

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

它们是原始的,而不是指向对象的指针(你需要星号来指示它)。

答案 1 :(得分:5)

应该是NSUInteger varName,而不是NSUInteger * varName。它们是原始的。