Firstly, just a quick hello to the community!
I'm new this week to IPhone app development, and Macs in general; my obj c skills are new (it's been some 15 years since I dabbled in C), but I have many years in some other languages (ColdFusion, SQL etc).
I've read a lot of recommended documentation, and jumped in the deep end with my first application; perhaps somewhat silly but that's how I've learned languages in the past!
Anyway, on with my problem - no doubt it's something utterly basic but I've been pulling my hair out for 2 days trying to find (or work out) an answer.
I'm trying to get a loaded image to move in response to a basic finger touch; I have borrowed the code from the "moveme" sample application and I have tried to integrate it into my existing project (which interface has been implemented through IB), however I am stuck on the one error and cant resolve it. TubeMap is the name of the object view holding the image (which is bigger than the view that holds it), which I have made of the class MoveMeView, which I believe is a subclass of UIImageView.
MoveMeView.h
MoveMeView.m
On compile, 1 error and 2 warnings
- tubeMap with a "comparison of distinct Objective-C types lacks a cast" (both warnings)
and more importantly
tubeMap.center = location; gives "request for member 'center' in something not a structure or union".
Now I think that means I'm trying to set a variable in my instance of TubeMap that doesn't exist, but it should be the centre of the image. So no doubt I'm doing something basic incorrectly. If anyone could help me out (a fix would be nice but an explanation of what I've done wrong would be even more helpful) I would be most grateful.
Thanks in advance!
I'm new this week to IPhone app development, and Macs in general; my obj c skills are new (it's been some 15 years since I dabbled in C), but I have many years in some other languages (ColdFusion, SQL etc).
I've read a lot of recommended documentation, and jumped in the deep end with my first application; perhaps somewhat silly but that's how I've learned languages in the past!
Anyway, on with my problem - no doubt it's something utterly basic but I've been pulling my hair out for 2 days trying to find (or work out) an answer.
I'm trying to get a loaded image to move in response to a basic finger touch; I have borrowed the code from the "moveme" sample application and I have tried to integrate it into my existing project (which interface has been implemented through IB), however I am stuck on the one error and cant resolve it. TubeMap is the name of the object view holding the image (which is bigger than the view that holds it), which I have made of the class MoveMeView, which I believe is a subclass of UIImageView.
MoveMeView.h
#import <UIKit/UIKit.h>
@class TubeMap;
@interface MoveMeView : UIView {
TubeMap *tubeMap;
}
@property (nonatomic, retain) TubeMap *tubeMap;
@end
MoveMeView.m
#import "MoveMeView.h"
@implementation MoveMeView
@synthesize tubeMap;
- (void)touchesBeganNSSet *)touches withEventUIEvent *)event {
// We only support single touches, so anyObject retrieves just that touch from touches
UITouch *touch = [touches anyObject];
if ([touch view] != tubeMap) {
return;
}
}
- (void)touchesMovedNSSet *)touches withEventUIEvent *)event {
UITouch *touch = [touches anyObject];
// If the touch was in the tubeMap, move the tubeMap accordingly
if ([touch view] == tubeMap) {
CGPoint location = [touch locationInView:self];
tubeMap.center = location;
return;
}
}
On compile, 1 error and 2 warnings
- tubeMap with a "comparison of distinct Objective-C types lacks a cast" (both warnings)
and more importantly
tubeMap.center = location; gives "request for member 'center' in something not a structure or union".
Now I think that means I'm trying to set a variable in my instance of TubeMap that doesn't exist, but it should be the centre of the image. So no doubt I'm doing something basic incorrectly. If anyone could help me out (a fix would be nice but an explanation of what I've done wrong would be even more helpful) I would be most grateful.
Thanks in advance!