Many iOS developers just take advice on optimizing their code for specific architectures without investigating details, like use this option in this case and that option in that case. Here is a great article that clarifies details of ARM for Apple's devices: A few things iOS developers ought to know about the ARM architecture.
Archive for July, 2010
A few things iOS developers ought to know about the ARM architecture
Monday, July 19th, 2010Bug In Split View-based Application Template
Monday, July 12th, 2010When you create a project using this template you get two controllers. One of them is DetailViewController that shows details of the selected item and also manages popover with items list. I've discovered that there is a subtle bug, and it hits you when you show another view controller modally.
Seems to be a rare case but I was showing registration screen, not that exotic feature!
How does it look like? Application loads and pulls data over the net to populate items list. When items list is ready the first item is set selected and shows in details controller. At this moment registration screen mysteriously disappears. Here is the code that updates details controller:
- (void)setDetailItem:(id)newDetailItem {
if (detailItem != newDetailItem) {
[detailItem release];
detailItem = [newDetailItem retain];
// Update the view.
[self configureView];
}
if (popoverController != nil) {
[popoverController dismissPopoverAnimated:YES];
}
}
When I stopped in debugger it became obvious: dismissPopoverAnimated: was called and it just dismisses the current modal view controller! So the fix is to check whether the popover is actually visible, and what interesting is that there is a property for this: popoverVisible. Here is the fixed version of the method:
- (void)setDetailItem:(id)newDetailItem {
if (detailItem != newDetailItem) {
[detailItem release];
detailItem = [newDetailItem retain];
// Update the view.
[self configureView];
}
if (popoverController && popoverController.popoverVisible) {
[popoverController dismissPopoverAnimated:YES];
}
}
The morale of the story: be precise when writing your code; avoid side-effects.