MessageBoxViewController.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // MessageBoxViewController.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 10/14/15.
  6. // Copyright © 2015 ntels. All rights reserved.
  7. //
  8. #import "MessageBoxViewController.h"
  9. #import "RequestHandler.h"
  10. #import "ModeModel.h"
  11. #import "CustomTableView.h"
  12. #import "CustomLabel.h"
  13. #import "CustomButton.h"
  14. #import "CustomImageView.h"
  15. @implementation MessageBoxTableViewCell
  16. @end
  17. @interface MessageBoxViewController () {
  18. NSMutableArray<PersonalNoticeModel> *_personalNoticeList;
  19. NSString *_pagingId, *_pagingType;
  20. }
  21. @end
  22. #pragma mark - Class Definition
  23. @implementation MessageBoxViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. // Do any additional setup after loading the view.
  27. _personalNoticeList = (NSMutableArray<PersonalNoticeModel> *)[[NSMutableArray alloc] init];
  28. [self initUI];
  29. [self prepareViewDidLoad];
  30. }
  31. - (void)initUI {
  32. [self initTableViewAsDefaultStyle:_tableView];
  33. }
  34. - (void)prepareViewDidLoad {
  35. [self requestPersonalNotices];
  36. }
  37. #pragma mark - Main Logic
  38. - (void)requestPersonalNotices {
  39. //parameters
  40. NSDictionary *parameter = @{@"push_hist_id": _pagingId ? _pagingId : ksEmptyString,
  41. @"paging_type": _pagingType ? _pagingType : ksEmptyString};
  42. NSString *path = API_GET_NOTICE_PERSONAL;
  43. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:parameter modelClass:[PersonalNoticeListModel class] completion:^(id responseObject) {
  44. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  45. return;
  46. }
  47. PersonalNoticeListModel *fetchedPersonalNoticeList = (PersonalNoticeListModel *) responseObject;
  48. if (fetchedPersonalNoticeList && fetchedPersonalNoticeList.list &&
  49. fetchedPersonalNoticeList.list.count) {//API 성공 ,
  50. [_personalNoticeList addObjectsFromArray:fetchedPersonalNoticeList.list];
  51. } else {//실패 시
  52. }
  53. [_tableView reloadData];
  54. } failure:^(id errorObject) {
  55. JDErrorModel *error = (JDErrorModel *)errorObject;
  56. [[JDFacade facade] alert:error.errorMessage];
  57. }];
  58. }
  59. #pragma mark - UITableView DataSource & Delegate
  60. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  61. return 1;
  62. }
  63. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  64. return _personalNoticeList.count;
  65. }
  66. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  67. CGFloat height = 160.0f;
  68. return height;
  69. }
  70. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  71. UITableViewCell *cell = nil;
  72. PersonalNoticeModel *notice = _personalNoticeList[indexPath.row];
  73. if (notice) {
  74. MessageBoxTableViewCell *tcell = (MessageBoxTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"PersonalNoticeCellIdentifier"];
  75. tcell.lblContent.text = notice.content;
  76. tcell.lblReadDatatime.text = notice.readDatetime;
  77. cell = tcell;
  78. }
  79. return cell;
  80. }
  81. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  82. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  83. }
  84. #pragma mark - UI Events
  85. - (IBAction)btnCloseTouched:(id)sender {
  86. [self dismissViewControllerAnimated:YES completion:nil];
  87. }
  88. #pragma mark - MemoryWarning
  89. - (void)didReceiveMemoryWarning
  90. {
  91. [super didReceiveMemoryWarning];
  92. // Dispose of any resources that can be recreated.
  93. }
  94. @end