Another “Initialization makes pointer from integer without a cast” question?

Remove the so that playerCount is an NSInteger and not a pointer to an NSInteger.

Up vote 1 down vote favorite share g+ share fb share tw.

I know there's already plenty of threads that start off this way. I'm reading that most of them are attempting to assign a value of type int to an NSInteger which I can understand is going to throw an error. However, I don't think that that's what I'm doing this time.

What I'm trying to do is get the value of the selectedSegmentIndex of a UISegmentedControl and then store that in an NSInteger variable. According to the UISegmentedControl Class Reference this property is an NSInteger as well. SelectedSegmentIndex The index number identifying the selected segment (that is, the last segment touched).

@property(nonatomic) NSInteger selectedSegmentIndex So here's the code: - (IBAction) continueClick:(id)sender { NSInteger *playerCount = sender selectedSegmentIndex; GameController. NumberOfPlayers = playerCount; } Pretty simple and basic. As far as I can tell anyway.

Iphone objective-c cocoa-touch uisegmentedcontrol link|improve this question edited Jun 27 '11 at 1:30Deepak20.1k31529 asked Jun 27 '11 at 1:13user816645314 80% accept rate.

Possible duplicate of initialization makes pointer from integer without a cast – Iulius Cæsar Jun 27 '11 at 2:00.

Remove the * so that playerCount is an NSInteger and not a pointer to an NSInteger: NSInteger playerCount = sender selectedSegmentIndex; NSInteger is a numeric type and not a class.

Correct answer, but doesn't explain why this is necessary. (i.e. That NSInteger is a numeric type and not a class) – jtbandes Jun 27 '11 at 3:10 Fair enough.

I've added that information to the answer. Thanks for that! Feel free to edit the answer yourself if you'd like to further expand or clarify.

Or, if you'd prefer, go ahead and write up your own answer. Either way. The main thing, of course, is to get the best possible answer one way or another.

– Trott Jun 27 '11 at 5:57.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions