KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am new to Objective C and Cocoa. I just don't get it how to message the superview of an UIView. I can't get it work. Here is what i tried so far: In my MainView i have a method named resetDrawType: - (void) resetDrawType { self.drawType = foo; } Also in the MainView i create a subview and add it to MainView: mySubView *mySubView = [[mySubView alloc] initWithFrame:CGRectMake(foo, foo, foo, foo)]; [self addSubview:mySubView]; [mySubView release]; Then when the subview finished its drawing i want to send the message resetDrawType to its superview, which is the MainView. I tried this [(MainView*)[self superview] resetDrawType]; and [(MainView*)self.superview resetDrawType]; …what didn't work. I learned about Informal Protocols so i added this code to MainView.h @interface NSObject ( resetters ) - (void) resetDrawType; @end But still nothing. Next i found out about this selector thing and tried this in the subview: if ([self.superview respondsToSelector:@selector(resetDrawType:)]) [self.superview performSelector:@selector(resetDrawType) withObject:nil]; It also didn't work. What am I doing wrong? Thanks for your help.
Tags (comma-separated)
Save Edits
Cancel