开发者

Accessing elements from an array in objective c

I am trying to access individual elements of my array. This is an example of the contents of the array i am trying to 开发者_运维知识库access.

<City: 0x4b77fd0> (entity: Spot; id: 0x4b7e580 <x-coredata://D902D50B-C945-42E2-8F71-EDB62222C0A7/Spot/p5> ; data: {
    CityToProvince = 0x4b7dbd0 <x-coredata://D902D50B-C945-42E2-8F71-EDB62222C0A7/County/p15>;
    Description = "Friend";
    Email = "bla@bla.com";
    Age = 21;
    Name = "Adam";
    Phone = "+44175240";
}),

The elements i am trying to access are Name, Phone, etc ...

How would i go about doing this?

UPDATE:

OK, understanding that I am looking at core data now, how would I go about removing an object from being displayed in my table view?

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    NSManagedObject *object = (NSManagedObject *)[entityArray objectAtIndex:indexPath.row];

    NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }



    // Configure the cell...

    return cell;
}


That doesn't look like an array. That looks like a Core Data entity. You may have an array of them, but it appears as though you're trying to access the members of the entity itself. To do so, you can use the NSManagedObject method -(id) valueForKey:.

NSManagedObject *entity = /* ... retrieve entity from Core Data ... */;
NSString *name = [entity valueForKey:@"Name"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜