• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Yet another stupid newbie's question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yet another stupid newbie's question


  • Subject: Re: Yet another stupid newbie's question
  • From: Guillaume Borios <email@hidden>
  • Date: Tue, 28 Aug 2001 13:17:01 +0200

Le mardi 28 ao{t 2001, ` 12:16 PM, email@hidden a icrit :

Hello list,

It's again around type conflicts, pointers and stuff... Probably I'm trying
to mix objects and c-style vars in a wrong way

I've done an array containing integers.
it's filled by:
...
[myArray addObject:[NSNumber numberWithInt:10]];
[myArray addObject:[NSNumber numberWithInt:123]];
[myArray addObject:[NSNumber numberWithInt:4]];
[myArray addObject:[NSNumber numberWithInt:56]];
...

A simple

for (index=0;index<max;index++) {
NSLog (@"debug --> %@", [myArray objectAtIndex:index]);
}

tells me that all values are stored fine.

Well, my question is, how can I do some mathematics (additions, comparing in
size) with this values???

int value=[myArray objectAtIndex:0] makes the compiler scream:
"assignment makes integer from pointer without a cast"... :-(

[myArray objectAtIndex:0] returns a pointer (type id) to the NSNumber Object stored at index 0. To get the value of the NSNumber object try :
int value = [[myArray objectAtIndex:0] intValue];

Refer to the cocoa foundation frameworks docs for more details (NSNumber and NSArray sections)...

Guillaume


References: 
 >Yet another stupid newbie's question (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: Multiple NIBs and -awakeFromNib problems
  • Next by Date: RE: Yet another stupid newbie's question
  • Previous by thread: Yet another stupid newbie's question
  • Next by thread: RE: Yet another stupid newbie's question
  • Index(es):
    • Date
    • Thread