@property (nonatomic) CGFloat *offsetPoint;
This property is storing a pointer to a float and it shouldn't be. Change it to:
@property (nonatomic) CGFloat offsetPoint;
Pergunta
I'm having a problem with CGFloat
. What I am trying to do is to set a value for the X of a UIScrollView
to do some actions when the user change page using a UIButton
to do that.
This is the error Xcode gives to me:
Incompatible integer to pointer conversion assigning to 'CGFloat *' (aka 'float *') from 'int'
This is my code:
.h
#import <UIKit/UIKit.h>
@interface MenuViewController : UIViewController <UIScrollViewDelegate>
{
}
@property (nonatomic) CGFloat *offsetPoint;
@property (weak, nonatomic) IBOutlet UIScrollView *trackSelectionScrollView;
@end
.m
- (void)scrollForward
{
self.offsetPoint = self.trackSelectionScrollView.contentOffset.x; // Error here
if ((self.offsetPoint = 0)) // Error here
{
[self.trackSelectionScrollView setContentOffset:CGPointMake(320, 0) animated:YES];
}
if ((self.offsetPoint = 320)) // Error here
{
[self.trackSelectionScrollView setContentOffset:CGPointMake(640, 0) animated:YES];
}
if ((self.offsetPoint = 640)) // Error here
{
//Last page do nothing
}
}
If you can't understand the problem with the code I've posted I will post more of it :-)
Solução
@property (nonatomic) CGFloat *offsetPoint;
This property is storing a pointer to a float and it shouldn't be. Change it to:
@property (nonatomic) CGFloat offsetPoint;