你发现采用C/C++的&传递地址函数参数编译器报错。那么做到给函数传递地址,让函数改变参数对象的指针呢?
解决办法:我们不能直接修改对象的地址,但是可以通过修改对象的成员函数指针的指向来变相实现对象地址的
转变。当然你可以采用定义一个本页面对象的对象,传递参数的编号来实现修改那个成员变量。
@interface PPHotListEntity : PPJoyListEntity
@property (nonatomic, assign) NSUInteger page;
@property (nonatomic, assign) NSInteger cate_id;
@property (nonatomic, assign) BOOL is_hot;
@property (nonatomic, assign) long long receiveTime;
//@property (nonatomic, assign) long long newsMessageTime;
@property (nonatomic, strong) PPHotMessageEntity *firstMessage;
@property (nonatomic, strong) PPHotMessageEntity *secondMessage;
@property (nonatomic, strong) PPHotMessageEntity *thirdMessage;
@property (nonatomic, strong) PPHotMessageEntity *fouthMessage;
@property (nonatomic, strong) NSMutableArray *roomList;
@property (nonatomic, strong) NSMutableArray *messageList;
@property (nonatomic, assign) BOOL is_page;
@end
-(void)moveMessageViewWithDecHotMessageView:(PPHotMessageView *)decHotMessageView decHotMessageEntityIndex:(NSUInteger)decHotMessageEntityIndex srcHotMessageEntity:(PPHotMessageEntity *)srcHotMessageEntity
{
if(1 == decHotMessageEntityIndex)
{
self.hotListEntity.firstMessage = [[PPHotMessageEntity alloc] initWithHotMessageEntity:srcHotMessageEntity];
decHotMessageView.hidden = NO;
decHotMessageView.model = self.hotListEntity.firstMessage ;
}
else if(2 == decHotMessageEntityIndex)
{
self.hotListEntity.secondMessage = [[PPHotMessageEntity alloc] initWithHotMessageEntity:srcHotMessageEntity];
decHotMessageView.hidden = NO;
decHotMessageView.model = self.hotListEntity.secondMessage ;
}
else if(3 == decHotMessageEntityIndex)
{
self.hotListEntity.thirdMessage = [[PPHotMessageEntity alloc] initWithHotMessageEntity:srcHotMessageEntity];
decHotMessageView.hidden = NO;
decHotMessageView.model = self.hotListEntity.thirdMessage ;
}
else if(4 == decHotMessageEntityIndex)
{
self.hotListEntity.fouthMessage = [[PPHotMessageEntity alloc] initWithHotMessageEntity:srcHotMessageEntity];
decHotMessageView.hidden = NO;
decHotMessageView.model = self.hotListEntity.fouthMessage ;
}
}