You probably declared your index
property in your PhotoViewController
class as NSUInteger *index
instead of just NSUInteger index
. Get rid of the asterisk.
NSUInteger incompatible with NSUInteger?
-
03-08-2022 - |
Question
index
is a NSUInteger
on both my parent and child view controller. But when I try to pass the NSUInteger
value for index
I get a warning on this line: controller.index = index;
saying "incompatible integer to pointer conversion assigning to NSUInteger from NSUInteger" and tells me to fix-it with &(index)
. But when I convert it to &(index)
I no longer get a number value from index
. What am I doing wrong? (new to programming) thanks!
- (PhotoViewController *)viewControllerAtIndex:(NSUInteger)index storyboard:(UIStoryboard *)storyboard
{
self.image = [self photoAtIndex:index];
if (self.image == nil) {
return nil;
}
PhotoViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"PhotoViewController"];
controller.image = self.image;
controller.index = index;
return controller;
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow