07-11-2010, 10:19 AM
#1 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 4
New hand Q: how to pass a valuable into a ref
Hello,
i am a totally new hand, please help.
I keep getting error in following code.
Please help.
thank you
Fming
NSString* message;
Int Random_number1;
random_number1= 1+arc4random()%100;
message= [NSString stringWithFormat: @"%d", random_number1] ;
07-11-2010, 10:47 AM
#2 (permalink )
Registered Member
Join Date: Jun 2009
Posts: 259
1. variable names are case sensitive
2. its "int" or "NSInteger", not Int
Code:
NSString* message;
NSInteger random_number1; // resp. "int random_number1;"
random_number1= 1+arc4random()%100;
message= [NSString stringWithFormat: @"%d", random_number1] ;
07-11-2010, 11:07 AM
#3 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 4
Quote:
Originally Posted by
finefin
1. variable names are case sensitive
2. its "int" or "NSInteger", not Int
Code:
NSString* message;
NSInteger random_number1; // resp. "int random_number1;"
random_number1= 1+arc4random()%100;
message= [NSString stringWithFormat: @"%d", random_number1] ;
I think it is not the case,
i have try to change int -> NSInteger
it get the same problem
07-11-2010, 11:29 AM
#4 (permalink )
Registered Member
Join Date: Jun 2009
Posts: 259
did you change "Random_number1" to "random_number1"?
That's what I meant with "
case sensitive ".
I tested the snippet i posted and it works like a charm.
07-11-2010, 11:30 AM
#5 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
What is the error message that you get?
07-11-2010, 11:36 AM
#6 (permalink )
Registered Member
Join Date: Jun 2009
Posts: 259
let me guess. it's
Code:
'random_number1' undeclared (first use in this function)
Unused variable ‘Random_number1'
is it?
07-11-2010, 08:31 PM
#7 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 4
Sorry no
I think it related to "message" is a pointer
But I pass a value into it directly
If I change the code to:
Message =@"helloworld";
It working well
I do not know how to pass a valuable .
Like:
Message=@random_number1;
Thanks
07-11-2010, 09:16 PM
#8 (permalink )
Emphasizing Fundamentals
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
Post the exact code you are trying. No retyping; copy and paste.
And post the exact error message you are receiving.
I will not ask again.
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 330
16 members and 314 guests
akphyo , alexP , appservice , cgokey , EXOPTENDAELAX , flamingliquid , guusleijsten , mariano_donati , ohmniac , Paul Slocum , PavelSea , SLIC , Sloshmonster , Sonuye857 , v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac