Search code examples
objective-ciosios5ios6ios5.1

-[UITableView setStyle:] in iOS 6 crashing the app (but not in iOS 5.1)


For some reasons we have situations when we have to set properties from a NSDictionary to an UIView.
Everything was OK 'till the iOS 6 was released. Now -[UITableView setValue:value forKey:@"style"] is crashing the app. In iOS 6 it calls setValue:forUndefinedKey: but in iOS 5.1 it doesn't (and everything is OK then). I know that style UITableView's property is read-only but... why? I have my own implementation of setValue:forUndefinedKey: but I don't want to filter somehow such properties (it'll be difficult to).


Solution

  • I know that style UITableView's property is read-only but... why?

    Because Apple decided to be so, and they probably have a pretty good reason for it. Don't try setting readonly properties, they will crash your app.