2

I wrote code.

But its code happen warning.

Its warning text is

Incompatible integer to pointer conversion assigning to 'NSInteger *' (aka 'int *') from 'NSInteger' (aka 'int')

This is code that is causing the warning.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    ...

    apd.newyear = [newys integerValue];//Its error happen on this row.

    apd.newmonth = [newms integerValue];//Its error happen on this row.

    [self dismissViewControllerAnimated:YES completion:nil];

}
Rukkora
  • 186
  • 2
  • 11

4 Answers4

13

The error is pretty clear.

newyear and newmonth both have type NSInteger * and you're trying to assign a NSInteger to them.

NSInteger is not an object, it's native C value, so you probably made a mistake in defining the two properties on your apd object.

I bet you have something like

@property NSInteger * newyear;

whereas it should be

@property NSInteger newyear;
Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
2

You have declared your NSInteger instance variables as pointers, which they shouldn't be (they are not objects):

@interface apd : NSObject
{
    NSInteger *newyear;
    NSInteger *newmonth;
}
...
@end

(or you've done this via @propertys):

@property (assign, nonatomic) NSInteger *newyear;
@property (assign, nonatomic) NSInteger *newmonth;

Just change them to plain NSInteger.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
2

I think you've declared newmonth and newyear as pointers...

@property (nonatomic) int *newyear;
@property (nonatomic) int *newmonth;

Just remove the * from these lines.

Fogmeister
  • 76,236
  • 42
  • 207
  • 306
0

i think this might be useful..try it

@interface abc : NSObject { NSInteger firstint; NSInteger secondint; } @property (nonatomic,readwrite) NSInteger firstint; @property (nonatomic,readwrite) NSInteger secondint; @end

iKambad
  • 351
  • 1
  • 2
  • 13