the problem is this…
I created a class that extends UIBezierClass called PathExtended, in which i added NSString ID;
I have, then, an array of PathExtended.
In the drawrect method i wrote:
p = [[PathExtended alloc] init];
for (int i=0; i<[arrayOfPaths count]; i++) {
[p appendPath:[arrayOfPaths objectAtIndex:i]];
[p closePath];
}
[p applyTransform:CGAffineTransformMake(a, b, c, d, e, f)];
[p fill];
Now, if i test in the touchend method:
if ([p containsPoint:pointTouched]) {
NSLog(@"There is!");
}
It’s ok!!! Instead, if i test:
if ([p containsPoint:pointTouched]) {
NSLog(@"ID= %@", p.ID);
}
Log is blank!!
I can understand why it happens, but, i can’t understand how solving problem.
I thought that appendPath creates a unique path, so, each single path information, like ID, is lost.
I thought also that, if i draw each path without using appendPath method i can solve the problem, but… i don’t know… it seems as if i’m following the wrong way.
Any idea???
Sorry for my english (i’m italian :P)
EDIT:
PathExtended .h
@interface PathExtended : UIBezierPath {
NSString* ID;
}
@property (nonatomic, readwrite) NSString* ID;
-(id) initwithID:(NSString*) _ID;
Imagine what would happen if you created a subclass of NSDecimalNumber, call it MyImaginaryNumber, such that your subclass stored an imaginary component. What would happen if you tried to call a method like
-decimalNumberByAdding:? You wouldn’t really expect NSDecimalNumber’s implementation of that method to include your imaginary part in the resulting number, would you? NSDecimalNumber obviously doesn’t know anything about the imaginary part, so it can’t be expected to do the right thing.If you want
-appendPath:to work with your PathExtended objects, you’ll need to override-appendPath:with an implementation that preserves the extra information in PathExtended. You can still call UIBezierPath’s implementation from inside your own if that’s useful, of course. For example, if your ID’s are composable, you might do something like:I’m not sure why your log message didn’t print at all, if that’s what happened, but it’s likely due to UIBezierPath not having an
IDproperty.