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 02-16-2011, 06:22 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 58
mavris is on a distinguished road
Default Assignment makes pointer from integer without a cast

Hello guys
I am getting this warning on iphone sdk.
this is the code:
- (IBAction)act1id)sender{
int int1 = [text1.text intValue];

NSString *key;
NSString *array1[10];

if(int1 >=128)
array1[0]= '1'; //warning here
else
array1[0]= '0'; //warning here

key = [NSString stringWithFormat:@"%c%c",array1[0],array1[1]];
label1.text = key;

Anyone know what is going wrong here?
mavris is offline   Reply With Quote
Old 02-16-2011, 06:30 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

'1' is not a number. And arrays can only hold objects, not simple data types. Use NSNumber instead or a plain C array.
baja_yu is offline   Reply With Quote
Old 02-16-2011, 06:43 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 58
mavris is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
'1' is not a number. And arrays can only hold objects, not simple data types. Use NSNumber instead or a plain C array.
But i want '1' to be as a single character in array[] of strings.
for C do you mean to use string array[10]...?

I mean "char array[10]...]
I get the same error
mavris is offline   Reply With Quote
Old 02-16-2011, 06:47 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 58
mavris is on a distinguished road
Default

I get the same error with NSNumber or char array[10]...
mavris is offline   Reply With Quote
Old 02-16-2011, 06:52 PM   #5 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

NSString *array1[10]; That's wrong.

NSArray *someArray = [NSArray arrayWithObject:[NSNumber numberWithChar:128]];

Check the documentation Loading…
There's also a NSMutableArray, which is, as name says, mutable.
baja_yu is offline   Reply With Quote
Old 02-16-2011, 07:11 PM   #6 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 58
mavris is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
NSString *array1[10]; That's wrong.

NSArray *someArray = [NSArray arrayWithObject:[NSNumber numberWithChar:128]];

Check the documentation Loading…
There's also a NSMutableArray, which is, as name says, mutable.
Thank you so much.
The issue was the *.

also is there any other way to prin this array other than this one?
key = [NSString stringWithFormat:@"%c%c%c%c%c%c%c%c",array1[0],array1[1],array1[2],array1[3],array1[4],array1[5],array1[6],array1[7]];

in C if string=array1[]; it assign all the characters to the string but its not working in objC
mavris 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: 363
11 members and 352 guests
cpsclicker, dre, Error404, gmarro, jeroenkeij, Kirkout, Music Man, PavelMik, teebee74, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,666
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, cpsclicker
Powered by vBadvanced CMPS v3.1.0

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