2012-08-10 86 views
0

裏面我有此數組:循環一個NSArray

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
NSString *firstname = [defaults objectForKey:kFirstName]; 
NSString *middlename = [defaults objectForKey:kMiddleName]; 
NSString *lastname = [defaults objectForKey:kLastName]; 
NSString *gender = [defaults objectForKey:kGender]; 
NSString *bloodtype = [defaults objectForKey:kBloodType]; 
NSString *civilstatus = [defaults objectForKey:kCivilStatus]; 
NSString *nationality = [defaults objectForKey:kNationality]; 

NSArray *nameArray = [NSArray arrayWithObjects:firstname, middlename, lastname, gender, bloodtype, civilstatus, nationality, nil]; 

我想創建數組檢查NSString對象在一個循環中爲空或有一個值。

目前,我有這樣的混亂,如果不使用數組聲明:

if (([firstname length] || [middlename length] || [lastname length] || [gender length] || [bloodtype length] || [civilstatus length] || [nationality length]) == 0) 
{ 
    NSLog(@"test1"); 
} 

我怎樣才能做到這一點?提前致謝!

回答