XYMyVoiceRoomListViewModel.m 1010 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // XYMyVoiceRoomListViewModel.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/7/7.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYMyVoiceRoomListViewModel.h"
  9. #import "XYMyVoiceRoomListModel.h"
  10. @implementation XYMyVoiceRoomListViewModel
  11. - (instancetype)init
  12. {
  13. self = [super init];
  14. if (self) {
  15. self.shouldPullDownToRefresh = YES;
  16. }
  17. return self;
  18. }
  19. - (void)loadData:(SuccessHandler)success failure:(FailureHandler)failure {
  20. [[XYVoiceRoomAPIManager new] getMyRoomsSuccessHandler:^(ZYLResponseModel *responseModel) {
  21. [self.dataSource removeAllObjects];
  22. for (NSDictionary *dict in responseModel.data[@"list"]) {
  23. XYMyVoiceRoomListModel *model = XYMyVoiceRoomListModel.new;
  24. [model yy_modelSetWithDictionary:dict];
  25. [self.dataSource addObject:model];
  26. }
  27. !success?:success(self.dataSource);
  28. } failureHandler:^(ZYLNetworkError *error) {
  29. !failure?:failure(error);
  30. }];
  31. }
  32. @end