我正在尝试在视图之间传递一个自定义类。我已经为该类设置了一个属性,但是当我访问该属性时,属性总是返回 null:
第一视图.m:
- (void)initNextEventView{
NSDate *eventDate = [eventDatePicker date];
NSString *eventName = eventNameTextfield.text;
LocateEventViewController *locView = [[LocateEventViewController alloc]init];
locView.eventDTO.name = eventName;
locView.eventDTO.date = eventDate;
[[self navigationController] pushViewController:locView animated:YES];
}
LocateEventVC.h(2.视图):
@interface LocateEventViewController : UIViewController<MKMapViewDelegate, UISearchBarDelegate, BSForwardGeocoderDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *imageBackground;
@property (strong, nonatomic) EventDTO *eventDTO;
因此,当我记录eventDTO的属性时,它返回 null ..
任何帮助都会很棒
编辑1(2.视图): 这就是我记录的方式:
NSLog(@"name on 2. view: %@", eventDTO.name);
self.eventDTO.place = tmpEventPlace;
// init friends view!
//passing to next view
EventMembersViewController *members = [[EventMembersViewController alloc]init];
members.eventDTO = self.eventDTO;
事件DTO.h
@interface EventDTO : NSObject
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) UserDTO * creatorIsAppUser;
@property (nonatomic, retain) ContactDTO * creatorIsNotAppUser;
@property (nonatomic, retain) NSString * description;
@property (nonatomic, retain) NSDate * date;
@property (nonatomic, readwrite) NSInteger *eventID;
@property (nonatomic, retain) CustomPlacemark * place;
@property (nonatomic, retain) NSMutableArray *invitedMembers;
@property (nonatomic, retain) NSMutableArray *acceptedMembers;
- (NSNumber*)getLatidude;
- (NSNumber*)getLongitude;
事件DTO.m
@synthesize place, date, eventID, name, acceptedMembers, description, invitedMembers;
- (NSNumber*)getLatidude{
return [NSNumber numberWithDouble:place.coordinate.latitude];
}
- (NSNumber*)getLongitude{
return [NSNumber numberWithDouble:place.coordinate.longitude];
}