Closed CocoaBob closed 11 years ago
The initialize method shouldn't be called more than once. Keep in mind here the method signature is - (void)initialize
and not + (void)initialize
(which has been known to get called more than once). Do you have an example where this method would get called more than once?
I use it in the -init method of a UITableViewController's subclass like this:
self.tableView = [BVReorderTableView new];
The call stack is always like this:
0 - [BVReorderTableView initialize];
1 - [BVReorderTableView initWithFrame:style:] <-
2 - [UITableView initWithFrame:]
3 - [BVReorderTableView initWithFrame] <-
4 - [UIView init]
5 - [BVReorderTableView init] <-
6 + [NSObject new]
And all the marked init methods will call [self initialize]
once, so here we have 3 times...
I tried [[BVReorderTableView alloc] init];
, it's the same.
Did I miss something?
You were correct. I've fixed the issue at a more critical step in the code so that the initialize method won't be called more than once. Thanks for your help!
If longPress gesture recognizer has already been added, we shouldn't add it again. Otherwise, the boolean canReorder won't work well if it's initialized multiple times.