Results 1 to 3 of 3
  1. #1
    Reference getting lost for a view / Retain count becoming 0 abruptly - xcode

    Member Since
    Jan 25, 2013
    Posts
    1
    Reference getting lost for a view / Retain count becoming 0 abruptly - xcode
    LiveScoreSettingsView * livescoreSettings;
    // initialisation in .h file inside @interface and no property is defined for this variable.

    // 1st method

    - (void)1stmethod: (id) callingClass username: (NSString*)username
    {

    livescoreSettings=callingClass; // retain count increases to 1
    isLivescoresSettingsView = YES;
    //.... some code where the above livescoreSettings variables are not used ... //

    }



    // 2nd method


    - (void)2ndmethod: (id) callingClass username: (NSString*)username matchid: (NSString *) matchid eventType: (NSString *) eventType add: (NSString *) add

    {

    livescoreSettings=callingClass;
    isLivescoresSettingsView = YES;
    addEventToList = YES;

    //.... some code where the above livescoreSettings variables are not used ... //
    }



    // delegate method thats activated when the response comes

    - (BOOL)xmppStream: (XMPPStream *)sender didReceiveIQ: (XMPPIQ *)iq
    {

    // the block where the data is sent to a particular view to reload table

    else if(isLivescoresSettingsView== YES || addEventToList == YES)
    {

    isLivescoresSettingsView=NO;
    addEventToList = NO;


    //.... some code where the above livescoreSettings variables are not used ... //

    if(success)
    NSLog(@"No Errors with retain count = %d ", [livescoreSettings retainCount]);
    else
    NSLog(@"Error Error Error!!!");

    [livescoreSettings.tableView reloadData];

    // when 2ndmethod is called there's no memory reference to livescoreSettings, tableView delegate methods are not called which is obvious. But not sure why the retain count is reducing abruptly.

    }

    }


    Whats happening is that 1st time i call that 1stmethod method everything works fine and the reference to the livescoreSettings is retained.

    Next when i call 2ndmethod method also the livescoreSettings ref is retained but by the time the delegate method gets activated the reference of that variable is lost.. dont know why...

  2. #2
    Reference getting lost for a view / Retain count becoming 0 abruptly - xcode
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    180
    Your code is not helping us much, I'm guessing your livescoreSettings is a view, or custom NSView object.

    What delegate methods ?, NSView does not have a delegate protocol, but can have a delegate assigned.
    where are the delegate methods located, eg. AppDelegate?

    why are you creating livescoreSetting from (id)callingClass?
    That would imply that the callingClass could be a different class type from NSView.

    in short you will have to help us to help you.

    If your instance variable is pointing to nil, then it has been released, or not initialized, in the case of
    an NSView class, it can bee released automatically when the view is removed from the screen, when
    you are using ARC memory managment.

    Also check the scope of your instance variables, make sure that all of the methods that use it, are able
    to see it.

    Also put your code snippets in code tags for posting, it makes it easier to read, for example.

    Code:
     myCode
    Sorry I could not be more help, but you will have to be more specific where your code is breaking down.

    Also put lots of NSLog(@""); statements in the critical program methods, so that you can track the
    changes in your variables.

    Regards Mark

  3. #3
    Reference getting lost for a view / Retain count becoming 0 abruptly - xcode
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    180
    It's just ocured to me that your problem may lie with the callingClass object, if at some point the callingClass object is released, then the livescroreSettings object will also be released or point to nil, as in the example code you have posted, livescroreSettings and callingClass are pointing at the same memory space, this is more likely if you are using ARC.

    Regards Mark

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to retain view settings for folders in Finder
    By rpincowes in forum OS X - Operating System
    Replies: 5
    Last Post: 02-13-2012, 12:53 PM
  2. How to animate when no reference to target view?
    By Earl Grey in forum iOS Development
    Replies: 0
    Last Post: 12-07-2011, 11:55 PM
  3. Missing View Button in XCode 4
    By zeta in forum iOS Development
    Replies: 4
    Last Post: 05-01-2011, 11:31 PM
  4. Xcode 4 unifies design and code view, available to all for $4.99
    By the8thark in forum Apple Rumors and Reports
    Replies: 0
    Last Post: 03-10-2011, 06:56 PM
  5. Ibook abruptly lost power and will not power on at all
    By cgeiber in forum Apple Notebooks
    Replies: 2
    Last Post: 08-14-2007, 09:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •