Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9203307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:26:40+00:00 2026-06-17T23:26:40+00:00

How can I pass a MutableArray with full of Objects to another class by

  • 0

How can I pass a “MutableArray with full of Objects” to another class by using NSUserDefaults? I know how to pass “MutableArray“s but this does not work!

So;

I have a MutableArray; ‘myCityObjects‘, and I populate it with objects; ‘cities‘
In each ‘cities‘ object there are properties like cityName, cityLocation etc…

[myCityObjects addObject:cities];

Now, what I want to do is to pass this MutableArray (filled with objects) to another class by using ‘NSUserDefaults‘;

[[NSUserDefaults standardUserDefaults] setObject: myCityObjects forKey:@"MCO"];

And in the other class,

NSMutableArray *getMyCityObjects = [[NSArray alloc] init];

getMyCityObjects = [[NSUserDefaults standardUserDefaults] mutableArrayValueForKey:@"MCO"];

But it doesn’t work! I cannot get myCityObjects in the other class, “getMyCityObjects” is empty. How can I fix that?

Thanks,
E.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:26:42+00:00Added an answer on June 17, 2026 at 11:26 pm

    Your array is nil because the objects in it (your custom objects) can’t be serialised.

    Please take a look at the NSCoding protocol. Objects you want to serialise (eg for writing to NSUserDefaults) must implement the methods -encodeWithCoder: and -initWithCoder.

    I’m sure you’ll find how this is rather easily done searching for the terms I gave you…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can pass a method like this: Class A: public void foo(Action<Class,
I know that you can pass in an initial argument using the sys.argv, but
I know that you can pass data to a view using: navigator.pushView(views.LoadoutView, list.selectedItem) But
In Delphi you can pass class references around to compare the types of objects,
Root entity can pass transient references to internal entities to external objects , but
I know that I can pass formset to inlineformset_factory and this by default takes
Does anyone know if I can pass data from flash (action script) to java
I can pass values form one page to another but I need to pass
I can pass a variable from MVC ASP.NET by using this : var lastCategoryId
I know you can pass a format to JFormattedTextField constructor, but how would you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.