New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Reference getting lost for a view / Retain count becoming 0 abruptly - xcode


Post Reply New Thread Subscribe

 
Thread Tools
Sharanya

 
Member Since: Jan 25, 2013
Posts: 1
Sharanya is on a distinguished road

Sharanya is offline
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...
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 168
Mark FX has a spectacular aura about

Mark FX is offline
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
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 168
Mark FX has a spectacular aura about

Mark FX is offline
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
QUOTE Thanks

Post Reply New Thread Subscribe


« Problem with cout, complex type on Xcode | getglobalpolicy in MAC OSX 11 is not returning all the values »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Lost Normal view in Msword 2008 for mac Haider OS X - Apps and Games 5 10-20-2009 10:05 AM
Finder and lost view of USB devices elrayox Switcher Hangout 4 10-25-2008 08:22 AM

All times are GMT -4. The time now is 01:00 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?