Two more iPhone SDK facts you may not know

Here are two other fun facts I discovered about the iPhone SDK:

1. You can present a modal view controller on top of another modal view controller

This would appear to contradict fact #2 from my posting of July 13th, but I have learned some new information. In my previous attempts to stack up modal view controllers, I was sending the presentModalViewController method call to the navigation controller defined in my app delegate. For the second modal view controller, if I just send the presentModalViewController method call in the first view controller to self, all works as it should.

2. Watch your colons on delegate selectors

I was trying to wire up a cancel delegate call that passed no parameters back to the caller, since none are necessary. However, the cancel delegate that I copied and changed from the working accept delegate was never firing in the following code:

if (delegate && [delegate respondsToSelector:@selector(myDelegateCancelPressed:)]) {
    [delegate myDelegateCancelPressed];
}

After I removed the colon from inside the @selector, it worked right as rain.

Leave a Reply