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
0
votes
1 answer

Casting big NSInteger to float issue

1) define big NSInteger 2) cast to float 3) log float 4) turns into slightly smaller number every time??? NSInteger val = 485935336; float val_float = (float)val; NSLog(@"%f", val_float); //logs 485935328, not 485935336 Any clue why?
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
0
votes
1 answer

Issue while parsing timestamp into date and time using Objective-C

I am getting timestamp for server in stringFormat which is in miliseconds. I have to convert it in date and time and display to the user. I have done it using following code: + (NSString…
Rahul
  • 5,594
  • 7
  • 38
  • 92
0
votes
2 answers

Can you downcast a NSIndexPath to NSInterger

I have a AVPlayer class that I'm using in a detail view that takes a indexPath of type Int. I am getting the indexPath from the table view tableViewDidSelectAtIndexPath before sending it to the detail VC to use. I tried to just simply downcast the…
user4671001
  • 309
  • 2
  • 4
  • 12
0
votes
1 answer

objectatindex outside of loop?

This is a question hard to ask but I'm going to give it a shot anyways. I'm trying to retrieving the contents of an NSDictionary outside of the UITableCell loop. Right now, when I do retrieve its content via: - (UITableViewCell…
HalesEnchanted
  • 615
  • 2
  • 9
  • 20
0
votes
1 answer

NSInteger not equal to long?

I am trying to parse some json data in Cocoa and I am having troubles with the NSInteger data type. The json string has some long values that I assign to NSInteger properties. Unfortunately the assigned NSInteger value differs completely from the…
ok404
  • 352
  • 2
  • 13
0
votes
2 answers

NSInteger losing value when saved in NSUserDefaults

When the following code executes, it logs "0" even though the indexPath.row selected is "1". NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSInteger location = indexPath.row; [userDefaults setInteger:location…
somepers
  • 529
  • 2
  • 6
  • 9
0
votes
1 answer

Reading integer from Core Data

In my app I have a Core Data entity called Status with two attributes messageID as Integer32 and messageText as String. I have a string stored in an SQL database which the app downloads on startup. The string from the database is broken down into…
RGriffiths
  • 5,722
  • 18
  • 72
  • 120
0
votes
1 answer

Difficulty writing number value back to Core Data

I have a Core Data entity called Status with two attributes savedMessageID as Integer32 and savedMessageText as String. I have a string stored in an SQL database which the app downloads on startup. The string from the database is broken down into…
RGriffiths
  • 5,722
  • 18
  • 72
  • 120
0
votes
4 answers

Split double-digit NSInteger into Two NSIntegers

I am trying to figure out how to take a double-digit NSInteger on iOS (like 11) and turn it into 2 separate NSIntegers, each looking like "1". It will always be just 2 digits in the NSInteger, no more, no less, and no decimals.
user717452
  • 33
  • 14
  • 73
  • 149
0
votes
1 answer

Why is the value changing when I cast an int to an NSInteger?

I have an NSDictionary, and I perform objectForKey for key resource_type_id: NSInteger resourceTypeID = [self.selectedDictionary objectForKey:@"resource_type_id"]; When I print resourceTypeID in the console, it returns 2 (the correct ID). Now, I…
joe
  • 267
  • 3
  • 8
0
votes
1 answer

NSInteger crazy value when incrementing

I've been looking for this problem for quite some time now, so I decided to ask. I seriously don't know what is going on. I have a tableView and when I select a cell I want it to go to a different view controller. So far all good, the thing is I…
0
votes
3 answers

Converting NSIndexPath to NSInteger in Swift

I have a UITableView with a segue that connects to a view controller. When the user taps on a cell, I would like the indexPath.row to be passed to that view controller so I can update the content in the view based on which cell has been tapped. I am…
user3746428
  • 11,047
  • 20
  • 81
  • 137
0
votes
1 answer

How can I cast an NSString as a hex representation of NSInteger

Cast is not the right word, but bear with me. I have the following string: NSString *string = @"01700000"; However, I need to check if it contains a particular bit I'm looking for: if (bitshift & (1 << 21)) { NSLog(@"YES"); } else { …
squarefrog
  • 4,750
  • 4
  • 35
  • 64
0
votes
3 answers

Incorrect value for sum of two NSIntegers

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) { …
Antonio
  • 863
  • 1
  • 11
  • 23
0
votes
1 answer

NSTimer not working accurately.

I am trying to make a countdown timer, however I am struggling with my code. I have a UIDatePicker to select the date to countdown to, but ever every time I try to do a countdown the seconds start at 54 seconds instead of adjusting to the actual…