Я новичок, у меня есть проблемы с NSArray.
Я создал массив и добавил новый объект (класс данных) в locationArray
dataclass.m
@synthesize UniqueID,name, address, latitude, longitude, type;
+ (id)LocationWithID:(NSString *)UniqueID name:(NSString *)name address:(NSString *)address latitude:(NSString *)latitude longitude:(NSString *)longitude type:(NSString *)type
{
agilentLocation *newLocation = [[self alloc] init];
newLocation.UniqueID = UniqueID;
newLocation.name = name;
newLocation.address = address;
newLocation.latitude = latitude;
newLocation.longitude = longitude;
newLocation.type = type;
return newLocation;
}
Table.m
NSMutableArray *LocationArray;
[LocationArray addObject:[dataclass LocationWithID:UniqueID name:name address:address latitude:latitude longitude:longitude type:type]];
Я хотел бы спросить, как я могу назвать значение под моим классом данных.Например, мне нужно назвать имя под классом данных для заголовка таблицы.
Обычно, когда я строю таблицу, я буду использовать
cell.textLabel.text = [LocationArray objectAtIndex:indexpath.row];
, но в этом случае есть только один объект, который является «классом данных», но у него есть несколько объектов под ним.как отображать имя в таблице.
Приведенный ниже код используется для распечатки значений для объекта (класс данных)
for (dataclass *theLocation in LocationArray) {
NSLog(@"Name: %@ Address: %@ Latitude: %g Longitude: %g Type :%@", theLocation.name, theLocation.address ,[theLocation.latitude doubleValue], [theLocation.longitude doubleValue], theLocation.type);
}
Снимок экрана
![enter image description here](https://i.stack.imgur.com/qug04.png)