Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Nic Huang
PLUS
Nic Huang
Courses Plus Student 10,573 Points

Retrieving Data from Parse

In the video, we declare an NSArray instance "messages" to retrieve PFObjects, which are messages sent to recipients in this case. But I am wondering why we don't have to make it NSMutableArray since messages keep coming?

1 Answer

David Kaneshiro Jr.
David Kaneshiro Jr.
29,247 Points

I believe that an NSArray is used instead of an NSMutableArray is because of the way we retrieve the messages from Parse. Every time we load the inbox screen we always grab all the messages stored in our inbox and replace the old array of messages with a new array. Since we don't only retrieve new messages from our inbox, we don't have the need to append individual messages to the array. We are always rebuilding the entire array every time we load the inbox screen.

Nic Huang
Nic Huang
Courses Plus Student 10,573 Points

Thanks for your explanation!! It's really helpful.