0
我有這個解析字符串的簡短方法。對象屬性未設置
NSMutableArray *aircraftMutableArray;
- (void)parseAircraftRotations:(NSString*)inText
{
aircraftMutableArray = [NSMutableArray array];
NSArray *inTextArray = [inText componentsSeparatedByString:@"\n"];
for (NSString*line in inTextArray)
{
if ([line length] > 0)
{
if ([[line substringToIndex:1] isEqualToString:@"-"])
{
aircraft = [[AirCraft alloc] init];
[aircraft setRegistration:[line substringFromIndex:1]];
[aircraftMutableArray addObject:aircraft];
aircraft = nil;
}
}
}
for (AirCraft *ac in aircraftMutableArray)
{
NSLog(@"%@", [ac registration]);
}
}
我現在的問題是,NSLog輸出正確的行數,但[ac註冊]在每行上爲空。請幫助。
什麼是你的[飛機註冊]方法是什麼樣子? –