From d4fec34ca8860eca93ce470dfc4296e652724a00 Mon Sep 17 00:00:00 2001 From: Miles Crabbe Date: Fri, 6 Jun 2014 09:30:52 -0500 Subject: [PATCH] -My Events (events the user has registered for) now appear under My UP --- .../project.pbxproj | 4 +- .../MyUPInitTableViewCell.xib | 8 +- .../UniversityPrograms/MyUPViewController.m | 89 +++++++++++++++++-- .../UniversityPrograms/MyUPViewController.xib | 27 +++++- .../PriorFeedbackTableViewCell.xib | 4 +- .../SpecificEventViewController.xib | 2 +- .../UpcomingEventsTableViewCell.xib | 2 +- 7 files changed, 117 insertions(+), 19 deletions(-) diff --git a/UniversityPrograms/UniversityPrograms.xcodeproj/project.pbxproj b/UniversityPrograms/UniversityPrograms.xcodeproj/project.pbxproj index b204864..0c49ef1 100644 --- a/UniversityPrograms/UniversityPrograms.xcodeproj/project.pbxproj +++ b/UniversityPrograms/UniversityPrograms.xcodeproj/project.pbxproj @@ -218,6 +218,7 @@ children = ( 1BB198C7193FA4530017A1D6 /* UIColor+UPColors.h */, 1BB198C8193FA4530017A1D6 /* UIColor+UPColors.m */, + 1BEC1BF8193914BE009DADEF /* UPDataRetrieval.m */, ); name = Utils; sourceTree = ""; @@ -225,8 +226,8 @@ 1B0A69081938D474005C821D /* Views */ = { isa = PBXGroup; children = ( - 1B0A690A1938D487005C821D /* Table Cells */, 1B0A69091938D47E005C821D /* Basic Views */, + 1B0A690A1938D487005C821D /* Table Cells */, ); name = Views; sourceTree = ""; @@ -470,7 +471,6 @@ 1BEC1BFD1939183C009DADEF /* NSObject+ObjectMap.h */, 1BEC1BFE1939183C009DADEF /* NSObject+ObjectMap.m */, 1BEC1BF7193914BE009DADEF /* UPDataRetrieval.h */, - 1BEC1BF8193914BE009DADEF /* UPDataRetrieval.m */, 1B38F299193F6FD2005158D1 /* UPWebserviceConstants.h */, ); name = "Web Calls"; diff --git a/UniversityPrograms/UniversityPrograms/MyUPInitTableViewCell.xib b/UniversityPrograms/UniversityPrograms/MyUPInitTableViewCell.xib index 6abf74d..190ef4f 100644 --- a/UniversityPrograms/UniversityPrograms/MyUPInitTableViewCell.xib +++ b/UniversityPrograms/UniversityPrograms/MyUPInitTableViewCell.xib @@ -18,19 +18,19 @@ - + diff --git a/UniversityPrograms/UniversityPrograms/MyUPViewController.m b/UniversityPrograms/UniversityPrograms/MyUPViewController.m index 49c42ba..c0b7d77 100644 --- a/UniversityPrograms/UniversityPrograms/MyUPViewController.m +++ b/UniversityPrograms/UniversityPrograms/MyUPViewController.m @@ -18,10 +18,16 @@ #import "UPDataRetrieval.h" #import "NSObject+ObjectMap.h" #import "UIColor+UPColors.h" +#import "UpcomingEventsTableViewCell.h" +#import "SpecificEventViewController.h" @import QuartzCore; @interface MyUPViewController () @property (weak, nonatomic) IBOutlet UITableView *myUPTableView; @property NSArray *priorCommentArray; +@property NSArray *unsortedEventArray; +@property NSMutableArray *sortedEventArray; +@property (strong, nonatomic) IBOutlet UITableViewCell *yourEvents; + @property (strong, nonatomic) IBOutlet UITableViewCell *commentTitleCell; @property UIRefreshControl *refreshControl; @@ -38,6 +44,9 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil self.tabBarItem.image= [UIImage imageNamed:@"Cog.png"]; self.tabBarItem.selectedImage = [UIImage imageNamed:@"Cog_filled.png"]; self.priorCommentArray=[[NSArray alloc] init]; + self.unsortedEventArray=[[NSArray alloc] init]; + self.sortedEventArray=[[NSMutableArray alloc] init]; + return self; } @@ -51,7 +60,7 @@ - (void)viewDidLoad //self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"Add Comment" style:UIBarButtonItemStyleDone target:self action:@selector(didSelectComment)]; self.refreshControl = [[UIRefreshControl alloc] initWithFrame:CGRectMake(0, -60, self.myUPTableView.frame.size.width, 60)]; - [self.refreshControl addTarget:self action:@selector(loadFeedback) forControlEvents:UIControlEventValueChanged]; + [self.refreshControl addTarget:self action:@selector(loadData) forControlEvents:UIControlEventValueChanged]; [self.myUPTableView addSubview:self.refreshControl]; @@ -59,8 +68,37 @@ - (void)viewDidLoad // Do any additional setup after loading the view from its nib. } -(void)viewDidAppear:(BOOL)animated{ + [self loadData]; +} +-(void)loadData{ [self loadFeedback]; + [self loadEvents]; + + [self.refreshControl endRefreshing]; } +-(void)loadEvents{ + [UPDataRetrieval getEvents:[[NSUserDefaults standardUserDefaults] valueForKey:@"cwid"] completetionHandler:^(NSURLResponse *response, NSData *data, NSError *e) { + self.sortedEventArray=[[NSMutableArray alloc] init]; + self.unsortedEventArray=[NSObject arrayOfType:[Event class] FromJSONData:data]; + //NSLog(@"%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]); + NSArray *sortedArray = [self.unsortedEventArray sortedArrayUsingComparator:^NSComparisonResult(Event *event1, Event *event2) { + return [event1.startDate compare: event2.startDate]; + }]; + for (int index =0; index1 && indexPath.row + @@ -32,18 +33,38 @@ - + - + + + + + + + + + + + diff --git a/UniversityPrograms/UniversityPrograms/PriorFeedbackTableViewCell.xib b/UniversityPrograms/UniversityPrograms/PriorFeedbackTableViewCell.xib index c022671..684bec8 100644 --- a/UniversityPrograms/UniversityPrograms/PriorFeedbackTableViewCell.xib +++ b/UniversityPrograms/UniversityPrograms/PriorFeedbackTableViewCell.xib @@ -6,7 +6,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/UniversityPrograms/UniversityPrograms/SpecificEventViewController.xib b/UniversityPrograms/UniversityPrograms/SpecificEventViewController.xib index a60f02c..839abfd 100644 --- a/UniversityPrograms/UniversityPrograms/SpecificEventViewController.xib +++ b/UniversityPrograms/UniversityPrograms/SpecificEventViewController.xib @@ -76,7 +76,7 @@ - +