-1

I'm extremely new to ios.

I'm trying to learn appDelegate method to pass data in my application. When I'm setting the value for the variable (appDelegate variable) it does set it @ that point of time but after 2 steps it shows it as out of scope. While retrieving it when I do this

myAppDelegate *appDelegate = (myAppDelegate *)[[UIApplication sharedApplication] delegate];    
    myClass *my = [appDelegate.myclass objectAtIndex:0];

It say to a few of my property of myClass.(checked using a breakpoint & the ramdom like sometimes it first and second next time it is the third one).

Does anyone know what I'm missing ??? Thank you for your help ! :)

StackFlowed
  • 6,664
  • 1
  • 29
  • 45
  • can you give more details? how is appDelegate.myclass defined? sometimes the debugger has trouble showing variable content well, what happens when you print your variable content with NSLog ? – talkol Dec 07 '11 at 08:44
  • I used a break point to check and it does have the correct value. UserProfile *up = [[[UserProfile alloc] init]initWithUsername:un password:pd address:ad zipcode:zip email:em emailSetting:es calenderSetting:cs]; [self.userprofile addObject:up]; self.userprofile is my variable. up variable is perfectly ok ! – StackFlowed Dec 07 '11 at 08:57
  • can you send me more details about your problem... – Mina Nabil Dec 07 '11 at 09:18

2 Answers2

0

You can't always trust the debugger to show you variable content well. If the debugger says it's not in scope, try to print out the variable content to the console with:

NSLog(@"%@", [appDelegate.myclass objectAtIndex:0]);

Only if this crashes/fails, you have an actual problem.

talkol
  • 12,564
  • 11
  • 54
  • 64
  • the outputof nslog is ... that means it is getting some memory allocation but i cannot read stuff in it ! – StackFlowed Dec 07 '11 at 09:18
  • this looks like you don't have a problem. the NSLog can't print out every type of object. If you have any string member inside UserProfile you can try to print it out just to be certain – talkol Dec 07 '11 at 09:22
  • Can you point towards the relevant file in your project? it's rather big :) – talkol Dec 07 '11 at 09:46
0

Try this.

 if([appDelegate.myclass objectAtIndex:0]!=nil)
 {
       //Do your Code
 }
 Else
 {
       //No Values
 }
Muhammed Ayaz
  • 111
  • 1
  • 9