-2

I have NSMUtableArray , which i need to get the objects name in it .

NSMutableArray *array1 =[NSMUtableArray alloc]init];
[array1 addObject:me];
//me is another array ]

How can i get the name of the object me, looking in array1 ?

Curnelious
  • 1
  • 16
  • 76
  • 150
  • 2
    What do you mean by the *name* of object `me`? – Jason Coco Feb 24 '14 at 07:45
  • 3
    possible duplicate of [How do I test which class an object is in Objective-C?](http://stackoverflow.com/questions/2055940/how-do-i-test-which-class-an-object-is-in-objective-c) – joao Feb 24 '14 at 07:47
  • Objects don't have names. Variables don't have any intrinsic relationship to their values; they're just labels to make coding easier. – jscs Feb 24 '14 at 08:04
  • Are you looking for the classname of me then NSLog("%@",[[array1 objectAtIndex i] class]); – SreeHarsha Feb 24 '14 at 09:02

1 Answers1

0

This is what you are looking for? The dictionary contains key-value pairs.

NSArray *arrayOfKeys = [NSArray arrayWithObjects:@"firstObj",@"secondObj", nil];
YourObjectclass *firstObject = ...;
YourObjectclass *secondObject = ...;
NSArray *arrayOfValues = [NSArray arrayWithObjects:firstArray,secondArray, nil];
NSDictionary *dict = [NSDictionary dictionaryWithObjects:arrayOfValues forKeys:arrayOfKeys];

[dict objectForKey:@"firstObj"]; // return (YourObjectclass*)firstObject

In your case, do the opposite. Swap arrays of keys and values​​. So, you can get the name of your object, if you will use object as key, and name of the object as value.

Oleg Sobolev
  • 3,286
  • 2
  • 16
  • 29