Questions tagged [nsinteger]

An NSInteger is a data type in Objective-C. It is used to describe an integer.

An NSInteger is data type in Objective-C used to describe an integer. When building 32-bit applications, NSInteger is a 32-bit integer. A 64-bit application treats NSInteger as a 64-bit integer.

258 questions
8
votes
5 answers

Why can't I use an NSInteger in a switch statement?

Why doesn't this work: NSInteger sectionLocation = 0; NSInteger sectionTitles = 1; NSInteger sectionNotifications = 2; switch (section) { case sectionLocation: // break; case sectionTitles: // break; case…
Rits
  • 5,105
  • 4
  • 42
  • 53
8
votes
1 answer

Can you set an NSInteger as NULL in Objective-C?

I am trying to set an NSInteger to NULL. Though the compiler does not give any error, but I am not sure if this is the right way to do it. Can you set an NSInteger as NULL in ios..? Or is it forbidden for some reason..? Or Should I set it to…
Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
7
votes
3 answers

adding NSInteger object to NSMutableArray

I have an NSMutableArray @interface DetailViewController : UIViewController { NSMutableArray *reponses; } @property (nonatomic, retain) NSMutableArray *reponses; @end and i'm trying to add in my array…
7
votes
1 answer

How do I get specific values from a NSIndexPath

I have a NSArray with NSIndexPaths inside of it NSArray *array = [self.tableView indexPathsForSelectedRows]; for (int i = 0; i < [array count]; i++) { NSLog(@"%@",[array objectAtIndex:i]); } The NSLog returns this: 2…
Heli0s
  • 119
  • 1
  • 1
  • 7
7
votes
4 answers

sort NSInteger using sortUsingComparator

I am trying to sort an array of NSObjects (a object is of a class). The object class has several variables which I am wanting to use to sort the objects in the array, the variables I am using to sort are of type NSString or NSInteger, I am confident…
HurkNburkS
  • 5,492
  • 19
  • 100
  • 183
6
votes
3 answers

NSIntegerMax vs NSUIntegerMax

NSUInteger index = [self.objects indexOfObject:obj]; if (index == NSNotFound) { // Success! Note: NSNotFound internally uses NSIntegerMax } if (index == NSUIntegerMax) { // Fails! } Why? I'm suppose to get an unsigned value as a result of…
Mustafa
  • 20,504
  • 42
  • 146
  • 209
6
votes
1 answer

How can I reverse the byte order of an NSInteger or NSUInteger in objective-c

This is a somewhat of a follow up to this posting but with a different question so I felt I should ask in a separate thread. I am at the point where I have four consecutive bytes in memory that I have read in from a file. I'd like to store these…
Scott
  • 16,711
  • 14
  • 75
  • 120
6
votes
1 answer

Is there a better way to avoid 'Sign comparison' warning when comparing NSIndexPath's row and NSArray count?

I turned 'Signed Comparision' (aka -Wsign-compare) warnings for my iOS project in XCode (surprisingly, it was off by default). After that lots of warnings like this appeared: /Users/michalciuba/projects/GlobeMobile/Classes/ACMailController.m:86:19:…
Michał Ciuba
  • 7,876
  • 2
  • 33
  • 59
5
votes
3 answers

Compare NSNumber with NSInteger

I spent some time today chasing down two bugs, and ended up fixing both of them using the same solution. Now that I have the solution, I was hoping to get some clarity behind it. I'm comparing an attribute from Core Data (Integer 16/NSNumber) with…
djibouti33
  • 12,102
  • 9
  • 83
  • 116
5
votes
2 answers

NSInteger counts times 4?

I don't understand why this NSInteger counter increments to exactly 4 times the true value of database rows. Maybe this is stupid but I really just don't get it... Thanks so far :) NSInteger *i; i = 0; for ( NSDictionary *teil in gText ) { …
LaK
  • 99
  • 1
  • 7
5
votes
2 answers

iOS - Implicit coercion to 32 bits in the database is not recommended

All, Please help, I think I am going mad, but I have an existing app which is designed for 32bit standard device. However, when I run on 64bit it's having problems, I am getting the following: CoreData: warning: Property 'jobId' is a 64 bit scalar…
Adam Rush
  • 101
  • 8
5
votes
2 answers

Convert int64_t to NSInteger

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.
Hugo Costa
  • 71
  • 1
  • 6
5
votes
1 answer

Odd issues with int and NSInteger

Have spent several hours on this and am sure I'm missing something completely obvious. I'm new to cocoa/objective c and rusty with pointers / objects, and thus would greatly appreciate someone (kindly!) pointing out where I'm going wrong. Here is…
5
votes
1 answer

May I use NSCoder::encodeInteger:forKey: and decodeIntegerForKey: methods with argument of type NSUInteger?

I need to encode and decode property of type NSUInteger with NSCoder. Is it safe to use NSCoder::encodeInteger:forKey: and NSCoder::decodeIntegerForKey: methods for that? The other way around that comes to my mind is to wrap the unsigned integer…
Rasto
  • 17,204
  • 47
  • 154
  • 245
5
votes
1 answer

NSMutableArray property initialization and updating

Suppose I have a @property that is an NSMutablearray that is to contain scores used by four objects. They will be initialized as zero and then updated during viewDidLoad and throughout operation of the app. For some reason, I can't wrap my mind…
Victor Engel
  • 2,037
  • 2
  • 25
  • 46
1 2
3
17 18