nsinteger

Is NSNumber overkill for an instance-level counter?

I'm new to Objective-C and Cocoa. I've read that NSInteger and NSNumber are preferred when working with simple integers because they're the "platform-safe" versions of the primitive numeric types (and in NSNumber's case, wrapped in an object). So, I need a counter in my class that gets incremented when an NSTimer fires. On an Apple fo...

Why don't I declare NSInteger with a *

I'm trying my hand at the iPhone course from Stanford on iTunes U and I'm a bit confused about pointers. In the first assignment, I tried doing something like this NSString *processName = [[NSProcessInfo processInfo] processName]; NSInteger *processID = [[NSProcessInfo processInfo] processIdentifier]; Which generated an error, after t...

Using MPMediaPlaylistPropertyPlaylistAttributes and bitwise operators on NSInteger- Objective C (iPhone)

Hello, and thanks in advance for you time. I am trying to filter out certain types of playlists for an iphone app (genius and On-the-go, specifically). the documentation says that the property attribute MPMediaPlaylistPropertyPlaylistAttributes will return the attributes associated with a playlist in the form of an NSNumber containing a...

Objective C - NSNumber, NSInteger, ...

What's the difference between NSNumber and NSInteger? Are there more primitives like these that I should know about/use? Is there one for floats? ...

valueForKey only returns memory address and not actually value

NSDictionary *topic = [spaces objectAtIndex:i]; NSInteger topicid = [topic valueForKey:@"TOPICID"]; when I run this and print out topic I get the following: Printing description of topic: <CFDictionary 0xdb2a70 [0x30307a00]>{type = mutable, count = 2, capacity = 12, pairs = ( 10 : <CFString 0xdb5300 [0x30307a00]>{contents = "TOP...

How to convert NSInteger to int

hi, e.g. NSInteger called a [a value] is a EXC_BAD_ACCESS how to convert NSInteger to int ? (only small numbers < 32 are used) ...

NSInteger versus int

What would be the reason to use an NSInteger vs an int in iPhone programming? Thanks. ...

NSArray of UIBarButtonItem Tag (i.e. NSInteger)

Is it true that you can't have an NSMutableArray of NSIntegers? When I try to add the values to the array and then print them out they're huge numbers (when if I print out the tag to NSLog they're 0,1,2,3 etc.). I'm trying to create an array of my UITabBarItem's tags so I can save the order and retrieve it later. Am I forced to do some ...

Why cocoa dont use same enum declaration style everywhere ?

I was wondering what is the rationale behind different styles of enum declaration on cocoa? Like this: enum { constants.. }; typedef NSUInteger sometype; Is the reason to use typedef to get assigments to NSUInteger to work without casting? Sometimes the typedef is either of NSInteger/NSUInteger, why not use NSInteger always? Is th...

How to convert NSNumber to NSInteger

How to convert an NSNumber to NSInteger ? ...

I have a question about NSInteger release.

DetailViewController.h @interface DetailViewController : UIViewController { NSInteger getInteger; NSNumber *getNumber; } @property (nonatomic, retain) NSNumber *getNumber; @property (nonatomic, retain) NSInteger getInteger => Doesn't work with warning. hi, guys. I have a question about NSInteger. I know that NSNumber is abl...

Convert int64_t to NSInteger

Hi all, How can i convert int64_t to NSInteger in Objective-C ? This method returns into score an int64_t* and I need to convert it to NSInteger: [OFHighScoreService getPreviousHighScoreLocal:score forLeaderboard:leaderboardId]; Thank you. ...

Int or NSInteger as object for method argument. Objective-C

Hi. I'm having some trouble passing a number as an argument for a method: -(void) meth2:(int)next_int; And to call that method i need this: int next_int = 1; [self performSelectorOnMainThread:@selector(meth2:) withObject:next_int waitUntilDone:NO]; //update next_int and call meth2 again at this point i get a "pointer from integer w...

Compare an int to an array of ints Obj-C

Hi.. How do i go about seeing if my integer is in an array of integers... eg i want to know if 7 is in an array of [ 1 3 4 5 6 7 8] any ideas? Thanks ...

NSInteger problem

How to use the NSInteger give example and simplecode ...

Incorrect value for sum of two NSIntegers

Hi everybody: I'm sure I'm missing something and the answer is very simple, but I can't seem to understand why this is happening. I'm trying to make an average of dates: NSInteger runningSum =0; NSInteger count=0; for (EventoData *event in self.events) { NSDate *dateFromString = [[NSDate alloc] init]; if (event.date != nil) { ...

NSInteger differences between CLI and GUI ?

I've been building a framework and writing unit tests in GHUnit. One of my Framework's accessor methods returns an NSInteger. I assert the expected value in the tests like this: GHAssertEquals(1320, request.port, @"Port number should be 1320"); When running my tests with an AppKit UI based frontend this assertion passes. However, w...

Check if Integer is Positive or Negative - Objective C

Hello, How can I tell in objective-c coding if an integer is positive or negative. I'm doing this so that I can write an "if" statement stating that if this integer is positive then do this, and if its negative do this. Thanks, Kevin ...

how to convert the value of nsarray to integer value

Hi friend, I working on grouped table view based work in that in that i want to convert the value of NSarray into integer for specifing to section value of numberOfRowsInSection but it throws expection on putting following code. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { int sec; if (...

Crazy problem when comparing NSInteger to int

I have a crazy problem when comparing an NSInteger to int, as follows: NSInteger count = [dictionary count]; if (count == 0) { // Do something } else { // Do something } When the count is zero, the snipped code in the if clause is run, but when the count number is changed, the snipped code in the if clause is not run (this is...