Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jjgraz

macrumors regular
Original poster
Feb 13, 2009
103
0
I have recently completed an exercise using two views, and the appDelegate to display a slider Value on a label on a different view from the slider itself. (label is updated with a refresh button.) It all works fine. Now i want to do the same thing, only send text from one view to the other. I tried to manipulate the code, but keep getting the error...(in something not a structure or union). Below is a snip of code of the action which dismisses the view and pulls the slider value.....I rather it pulled just a plain old UILabel and displayed the same text in my other UILabel in second view. Please let me know if you can help sort me out.

-(IBAction)returnToMainView{
XXXXAppDelegate *mainDelegate = (XXXXAppDelegate *)[[UIApplication sharedApplication]delegate];

mainDelegate.sli = slider.value;

[self dismissModalViewControllerAnimated:YES];
}



In second View where the value is retrieved:

-(IBAction)refresh{
XXXXAppDelegate *mainDelegate = (XXXXAppDelegate *)[[UIApplication sharedApplication]delegate];

NSString* convert = [NSString stringWithFormat:mad:"%f", mainDelegate.sli];

valueLBL.text = convert;

}

Thank you.
 

jjgraz

macrumors regular
Original poster
Feb 13, 2009
103
0
after the thing was working with the slider....I made another outlet for a UILabel hoping to just pass the text through to the other view into another label(example below.....name)....and the error pops up...

-(IBAction)returnToMainView{
XXXXAppDelegate *mainDelegate = (XXXXAppDelegate *)[[UIApplication sharedApplication]delegate];

mainDelegate.sli = name.value;

Error: request for member 'value' in something not a structure or union.

[self dismissModalViewControllerAnimated:YES];
}

also tried: name.text
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
If 'name' is a UILabel, it doesn't have a 'value' property. Try 'text' instead.

P.S. It's a good idea to check the class references to find out what properties and methods are available to use.
 

jjgraz

macrumors regular
Original poster
Feb 13, 2009
103
0
name is actually a UILabel. I did already try name.text, as it was the first thing that came to mind....however,.....it comes back with error: incompatible type for argument 1 of 'setSli.

-(IBAction)returnToMainView{
XXXXAppDelegate *mainDelegate = (XXXXAppDelegate *)[[UIApplication sharedApplication]delegate];

mainDelegate.sli = name.text;

ERROR: incompatible type for argument 1 of 'setSli.

[self dismissModalViewControllerAnimated:YES];
}


When I set up the variable Sli in appdelegate.....I did it as a double...see below.

double sli;
.......more code.....

@property (nonatomic) double sli;

Is this why i'm being told its an incompatable type? I understand double is used for integers, but what is the alternative within the appDelegate for just passing through a text variable? It doesn't work if i type just IBOutlet sli;
should it be a NSString you think? IBoutlet NSString sli;
 

admanimal

macrumors 68040
Apr 22, 2005
3,531
2
sli is a double, name.text is an NSString. You can't make the assignment without converting the text to a double.
 

jjgraz

macrumors regular
Original poster
Feb 13, 2009
103
0
can I make it easy on myself and make sli a NSString instead, eliminating any need for converting? Thus making the name.text pass through the appdelegate seemlessly. There really is no need for values.
 

jjgraz

macrumors regular
Original poster
Feb 13, 2009
103
0
Alright. It works decalred as an NSString in appDelegate with name.text. I appreciate your help guys.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.