我有3节课。我试图像这样使用其中一个,但我知道有些事情是错的,但无法弄清楚我做错了什么。这是我的代码。 地点等级
results = [(4,[1],[4]),(5,[1],[5]),(6,[1],[6]),(7,[1],[7]),
(8,[2],[4]),(10,[2],[5]),(12,[2],[6]),(14,[2],[7]),
(12,[3],[4]),(15,[3],[5]),(18,[3],[6]),(21,[3],[7])]
reduce( ( lambda x,y: x if x[0]<y[0] else y), results )
位置等级
@interface Venue : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *venueId;
@property Location *location;
@property Stats *stats;
+(Venue*) sharedInstance;
-(void)getVenues:(NSString*)ll :(NSString*)query completionHandler:(void (^)(NSMutableArray *array))completionHandler;
@end
和统计类
#import <Foundation/Foundation.h>
@interface Location : NSObject
@property (nonatomic, strong) NSString *address;
@property (nonatomic, strong) NSString *city;
@property (nonatomic, strong) NSString *lat;
@property (nonatomic, strong) NSString *lng;
@property (nonatomic, strong) NSString *crossStreet;
@property NSNumber *distance;
@property (nonatomic, strong) NSString *cc;
@property (nonatomic, strong) NSString *country;
@end
当我尝试分配位置和统计值时,它返回null。
@interface Stats : NSObject
@property NSNumber *usersCount;
@property NSNumber *checkinsCount;
@property NSNumber *tipCount;
@end
我应该怎样做才能改变这种情况?
答案 0 :(得分:3)
在为其分配值之前,您需要实例化Stats和Location类。 肮脏的例子:
Venue *venue = [[Venue alloc] init];
venue.stats = [[Stats alloc] init];
venue.location = [[Location alloc] init];
答案 1 :(得分:0)
我还没有看到正在创建的对象属性,请确保所有对象都已初始化。