Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.