n.evermind
n.evermind

Reputation: 12004

How to access an object in an array stored in a class?

I guess this again quite basic, but how do I access an object in an array which belongs to a class?

My class is called NoteBook. In this NoteBook I have an array called tabReference. Imagine I have four objects in this array and would like to access the first at index 0.

I tried

int k = 0;    
currentNoteBook.tabReference[objectAtIndex:k];

but xCode tells me that objectAtIndex is undeclared. What would be the correct call?

Upvotes: 0

Views: 63

Answers (2)

William A
William A

Reputation: 121

And if you want access to the object in the class so can also do like this :

[self.tabReference objectAtIndex:k];

Upvotes: 0

Jesse Naugher
Jesse Naugher

Reputation: 9820

the correct way to access an array member in objective c for your example would be:

[currentNoteBook.tabReference objectAtIndex:k];

Upvotes: 3

Related Questions