| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- //
- // MessageBoxViewController.m
- // kneet2
- //
- // Created by Jason Lee on 10/14/15.
- // Copyright © 2015 ntels. All rights reserved.
- //
- #import "MessageBoxViewController.h"
- #import "RequestHandler.h"
- #import "ModeModel.h"
- #import "CustomTableView.h"
- #import "CustomLabel.h"
- #import "CustomButton.h"
- #import "CustomImageView.h"
- @implementation MessageBoxTableViewCell
- @end
- @interface MessageBoxViewController () {
- NSMutableArray<PersonalNoticeModel> *_personalNoticeList;
- NSString *_pagingId, *_pagingType;
- }
- @end
- #pragma mark - Class Definition
- @implementation MessageBoxViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- _personalNoticeList = (NSMutableArray<PersonalNoticeModel> *)[[NSMutableArray alloc] init];
-
- [self initUI];
- [self prepareViewDidLoad];
- }
- - (void)initUI {
- [self initTableViewAsDefaultStyle:_tableView];
- }
- - (void)prepareViewDidLoad {
- [self requestPersonalNotices];
- }
- #pragma mark - Main Logic
- - (void)requestPersonalNotices {
- //parameters
- NSDictionary *parameter = @{@"push_hist_id": _pagingId ? _pagingId : ksEmptyString,
- @"paging_type": _pagingType ? _pagingType : ksEmptyString};
-
- NSString *path = API_GET_NOTICE_PERSONAL;
-
- [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:parameter modelClass:[PersonalNoticeListModel class] completion:^(id responseObject) {
- if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
- return;
- }
-
- PersonalNoticeListModel *fetchedPersonalNoticeList = (PersonalNoticeListModel *) responseObject;
-
- if (fetchedPersonalNoticeList && fetchedPersonalNoticeList.list &&
- fetchedPersonalNoticeList.list.count) {//API 성공 ,
- [_personalNoticeList addObjectsFromArray:fetchedPersonalNoticeList.list];
-
- } else {//실패 시
-
- }
-
- [_tableView reloadData];
-
- } failure:^(id errorObject) {
- JDErrorModel *error = (JDErrorModel *)errorObject;
- [[JDFacade facade] alert:error.errorMessage];
- }];
- }
- #pragma mark - UITableView DataSource & Delegate
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return _personalNoticeList.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- CGFloat height = 160.0f;
-
- return height;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- UITableViewCell *cell = nil;
-
- PersonalNoticeModel *notice = _personalNoticeList[indexPath.row];
- if (notice) {
- MessageBoxTableViewCell *tcell = (MessageBoxTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"PersonalNoticeCellIdentifier"];
-
- tcell.lblContent.text = notice.content;
- tcell.lblReadDatatime.text = notice.readDatetime;
-
- cell = tcell;
- }
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [super tableView:tableView didSelectRowAtIndexPath:indexPath];
- }
- #pragma mark - UI Events
- - (IBAction)btnCloseTouched:(id)sender {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- #pragma mark - MemoryWarning
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|