我在UITableViewController
如何在iOS中的UITableViewController初始化屬性
@interface GinkgoDeliveryOrdersTableViewController : UITableViewController
@property PFQuery * query;
@property NSArray * products;
@end
我應如何初始化這兩個屬性的工作?目前,我在做延遲初始化:
@implementation GinkgoDeliveryOrdersTableViewController
@synthesize query = _query;
@synthesize products = _products;
- (void) initQuery {
_query = [PFQuery queryWithClassName:@"_Product"];
}
- (void) initProducts {
if(! _query)
[self initQuery];
_products = [_query findObjects];
}
結果,我想用這兩個屬性每一次,我必須做這樣的事情:
if(! self.products)
[self initProducts];
和
if(! self.query)
[self initQuery];
我覺得我在這裏做錯了事。是否有一個更清潔的方式做到這一點? 非常感謝!
非常感謝!我學到了很多! – Ra1nWarden