Accessing appDelegate NSString from other class

Discussion in 'iOS Programming' started by Xentarios, Jul 31, 2008.

  1. Xentarios macrumors newbie

    Jul 23, 2008
    Offending code: NSLog(@"name: %@",appDelegate.owner);

    Problem: appDelegate.owner is crashing the application.

    Interesting facts:

    owner is an NSString
    This line of code works correctly. self.navigationItem.title=@"test";
    There are no build errors or warnings.
    I have arrays being accessed in a similar way and they are working correctly.
    The difference between the things that are working as far as I can tell other than it being a string is that NSString conforms to the NSCopying protocol which makes me use copy instead of retain.
    The console doesn't seem to display anything useful when it crashes.
    owner is actually set and prints correctly to the console with NSLog from AppDelegate.

    @property (nonatomic, copy) NSString *owner;

    Any ideas would be appreciated. Here is a copy of the console output.

    [Session started at 2008-07-31 14:21:34 -0500.]
    Loading program into debugger…
    GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008)
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB. Type "show warranty" for details.
    This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
    warning: Unable to read symbols from "UIKit" (not yet mapped into memory).
    warning: Unable to read symbols for "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" (file not found).
    warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory).
    Program loaded.
    sharedlibrary apply-load-rules all
    Attaching to program: `/Users/Damien/Library/Application Support/iPhone Simulator/User/Applications/9B535DC4-43E7-4889-ADA2-7C8236F8384D/', process 4602.
    error while killing target (killing anyway): warning: error on line 1980 of "/SourceCache/gdb/gdb-960/src/gdb/macosx/macosx-nat-inferior.c" in function "macosx_kill_inferior_safe": (os/kern) failure (0x5x)

    The Debugger has exited with status 0.(gdb)
  2. Xentarios thread starter macrumors newbie

    Jul 23, 2008

    Apparently I need to reread the section on "self" :) Was missing that when setting owner. Owner was displaying inside the same method fine but not outside of it even in the appDelegate class. If anyone sees this behavior, that is probably your issue as well.
  3. GroundLoop macrumors 68000


    Mar 21, 2003
    I am running into this exact same problem. Where was your "self" issue?

  4. echel0n macrumors newbie

    Sep 29, 2008
    Not sure if this is helpful to your exact situation, but I stumbled across this thread when I was getting similar error messages from trying to draw an OpenGL texture.

    I found the problem was my draw() method was getting called too early, before the class init() method had returned. Which seems to fit with what Xentarios said.

Share This Page