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 3598800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:17:15+00:00 2026-05-18T20:17:15+00:00

I’m trying to share an NSArray object between several different view controllers and my

  • 0

I’m trying to share an NSArray object between several different view controllers and my first thought was to add a property on the app delegate as they all have access to this object.

But after some debugging it appears I can’t actually share this array for some reason. When I set the object from the first view controller and NSLog the results all is well. But when I attempt to get that array value using another view controller object it always returns UITouchData (not the value previously shown in the logs after my first view controller set the value)

Here is the code that I’m using to set the value

NSArray* cookies = [NSHTTPCookie 
                    cookiesWithResponseHeaderFields:[response allHeaderFields] 
                    forURL:[NSURL URLWithString:@""]];

  [appDelegate setAuthCookie:cookies];

Here is part of the .h for my app delegate

@interface SomeAppDelegate : NSObject <UIApplicationDelegate> {
  NSArray* authCookie;
}

@property (retain) NSArray* authCookie;

- (void)setAuthCookie:(NSArray *)cookie;
- (NSArray *)getAuthCookie;

@end

Here is the .m for the methods in question

@synthesize authCookie;

- (void)setAuthCookie:(NSArray *)cookie
{
  authCookie = cookie;  
}

- (NSArray *)getAuthCookie
{
  return authCookie;
}

Here is the attempt to grab this array in the second view controller that fails (technically it doesn’t fail on this line but I don’t get an NSArray back as expected so when I try to use this it fails)

NSArray* cookies = [appDelegate getAuthCookie];

Any way I can share state using the app delegate like this?

  • 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-05-18T20:17:16+00:00Added an answer on May 18, 2026 at 8:17 pm

    Your memory management is wrong, and you are getting a completely different object which has inherited the old array’s address when you later use the getter.

    Your @property is correct, but you’ve written your own setter and getter that do not retain the object. You don’t need to use both @property/@synthesize and supply your own getter/setter. The former is a newer means of automating the latter.

    If you remove your implementations of setAuthCookier: and getAuthCookie then your code should work.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string

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.