Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-11-2010, 10:19 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 4
fming is on a distinguished road
Default 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] ;
fming is offline   Reply With Quote
Old 07-11-2010, 10:47 AM   #2 (permalink)
Registered Member
 
finefin's Avatar
 
Join Date: Jun 2009
Posts: 259
finefin is on a distinguished road
Default

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 help you, you buy my app - you help me, I buy your app

PARALLAX, The Book Of Sayings - chopped up edition! (HD),omicron,
Canupa Band deluxe (universal), Canupa Band FREE!, Your Face --- follow me on twitter
finefin is offline   Reply With Quote
Old 07-11-2010, 11:07 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 4
fming is on a distinguished road
Default

Quote:
Originally Posted by finefin View Post
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
fming is offline   Reply With Quote
Old 07-11-2010, 11:29 AM   #4 (permalink)
Registered Member
 
finefin's Avatar
 
Join Date: Jun 2009
Posts: 259
finefin is on a distinguished road
Default

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.
__________________

I help you, you buy my app - you help me, I buy your app

PARALLAX, The Book Of Sayings - chopped up edition! (HD),omicron,
Canupa Band deluxe (universal), Canupa Band FREE!, Your Face --- follow me on twitter
finefin is offline   Reply With Quote
Old 07-11-2010, 11:30 AM   #5 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

What is the error message that you get?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 07-11-2010, 11:36 AM   #6 (permalink)
Registered Member
 
finefin's Avatar
 
Join Date: Jun 2009
Posts: 259
finefin is on a distinguished road
Default

let me guess. it's
Code:
'random_number1' undeclared (first use in this function)
Unused variable ‘Random_number1'
is it?
__________________

I help you, you buy my app - you help me, I buy your app

PARALLAX, The Book Of Sayings - chopped up edition! (HD),omicron,
Canupa Band deluxe (universal), Canupa Band FREE!, Your Face --- follow me on twitter
finefin is offline   Reply With Quote
Old 07-11-2010, 08:31 PM   #7 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 4
fming is on a distinguished road
Default

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
fming is offline   Reply With Quote
Old 07-11-2010, 09:16 PM   #8 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

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.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:34 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0