diff --git a/.DS_Store b/.DS_Store
index 130ecba..1644505 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/UserInterfaceState.xcuserstate b/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/UserInterfaceState.xcuserstate
index f03f6fa..0933578 100644
Binary files a/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/UserInterfaceState.xcuserstate and b/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
index d28b3c8..3f77b3c 100644
--- a/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ b/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -116,11 +116,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "MMI/HomeTableViewController.m"
- timestampString = "413364040.243194"
+ timestampString = "413406573.820451"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "155"
- endingLineNumber = "155"
+ startingLineNumber = "199"
+ endingLineNumber = "199"
landmarkName = "-prepareForSegue:sender:"
landmarkType = "5">
@@ -148,27 +148,53 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "MMI/HomeTableViewController.m"
- timestampString = "413364353.245975"
+ timestampString = "413406573.820451"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "154"
- endingLineNumber = "154"
+ startingLineNumber = "198"
+ endingLineNumber = "198"
landmarkName = "-prepareForSegue:sender:"
landmarkType = "5">
+
+
+
+
+
+
+
+
diff --git a/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/xcdebugger/Expressions.xcexplist b/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/xcdebugger/Expressions.xcexplist
index 6db8c17..c1c4f4a 100644
--- a/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/xcdebugger/Expressions.xcexplist
+++ b/MMI.xcworkspace/xcuserdata/jhilbert.xcuserdatad/xcdebugger/Expressions.xcexplist
@@ -18,6 +18,14 @@
+
+
+
+
+
+
diff --git a/MMI/Base.lproj/Main.storyboard b/MMI/Base.lproj/Main.storyboard
index 1497ac5..e4c3605 100644
--- a/MMI/Base.lproj/Main.storyboard
+++ b/MMI/Base.lproj/Main.storyboard
@@ -82,7 +82,7 @@
+
@@ -143,19 +144,43 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
diff --git a/MMI/CommentTableViewController.m b/MMI/CommentTableViewController.m
index e51bb1c..471bb36 100644
--- a/MMI/CommentTableViewController.m
+++ b/MMI/CommentTableViewController.m
@@ -69,8 +69,10 @@ - (IBAction)onAddCommentPressed:(id)sender {
PFObject *comment = [PFObject objectWithClassName:@"Comment"];
[comment setValue:commentTextField.text forKey:@"text"];
[comment setObject:currentUser forKey:@"createdByUser"];
+ [comment setObject:currentUser.username forKey:@"createdByUserName"];
[comment setObject:self.photo forKey:@"attachedToPhoto"];
[comment saveInBackground];
+ [self loadObjects];
}
#pragma mark - Table view data source
@@ -80,9 +82,9 @@ -(PFQuery *)queryForTable
PFQuery *queryComments = [PFQuery queryWithClassName:@"Comment"];
// [queryComments includeKey:@"createdByUser"];
// [queryComments includeKey:@"attachedToPhoto"];
- [queryComments orderByDescending:@"createdAt"];
- [queryComments whereKey:@"createdByUser" equalTo:currentUser.objectId];
- [queryComments whereKey:@"attachedToPhoto" equalTo:self.photo.objectId];
+ [queryComments orderByDescending:@"createdAt"];
+ // [queryComments whereKey:@"createdByUser" equalTo:currentUser];
+ [queryComments whereKey:@"attachedToPhoto" equalTo:self.photo];
return queryComments;
}
@@ -98,7 +100,8 @@ -(PFTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
- cell.textLabel.text = [object objectForKey:@"text"];
+ cell.detailTextLabel.text = [object objectForKey:@"text"];
+ cell.textLabel.text = [object objectForKey:@"createdByUserName"];
return cell;
}
diff --git a/MMI/FeedTableViewCell.h b/MMI/FeedTableViewCell.h
index 84ce195..7f56fa2 100644
--- a/MMI/FeedTableViewCell.h
+++ b/MMI/FeedTableViewCell.h
@@ -20,7 +20,7 @@
@property (weak, nonatomic) IBOutlet UIButton *likeButton;
@property UIButton *commentsButton;
@property UILabel *likesLabel;
-@property UILabel *commentsLabel;
+@property (weak, nonatomic) IBOutlet UILabel *commentsLabel;
@property PFObject *photo;
@end
diff --git a/MMI/HomeTableViewController.m b/MMI/HomeTableViewController.m
index 0288cb4..172495d 100644
--- a/MMI/HomeTableViewController.m
+++ b/MMI/HomeTableViewController.m
@@ -25,9 +25,10 @@ @implementation HomeTableViewController
- (void)viewDidLoad
{
self.parseClassName = @"Photo";
-
currentUser = [PFUser currentUser];
currentUserFollowingRelation = [currentUser relationforKey:@"following"];
+
+ self.view.backgroundColor = [UIColor orangeColor];
[super viewDidLoad];
}
@@ -50,7 +51,7 @@ -(PFQuery *)queryForTable
-(PFTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
FeedTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"a"];
-
+ NSLog(@"cell for row");
if (!cell)
{
cell = [[FeedTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"a"];
@@ -76,7 +77,7 @@ -(PFTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
PFUser *owner = object[@"user"];
cell.userLabel.text = owner.username;
- currentPhotoLikedByRelation = [object relationforKey:@"following"];
+ currentPhotoLikedByRelation = [object relationforKey:@"likedBy"];
PFQuery *query = [currentPhotoLikedByRelation query];
[query whereKey:@"username" equalTo:currentUser.username];
@@ -89,13 +90,54 @@ -(PFTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
[cell.likeButton setTitle:@"Do I Like this?" forState:UIControlStateNormal];
}
+ PFQuery *queryComments = [PFQuery queryWithClassName:@"Comment"];
+ [queryComments orderByDescending:@"createdAt"];
+ [queryComments whereKey:@"attachedToPhoto" equalTo:cell.photo];
+
+ cell.commentsLabel.lineBreakMode = NSLineBreakByWordWrapping;
+ cell.commentsLabel.numberOfLines = 0;
+
+ NSArray *comments = queryComments.findObjects;
+
+ cell.commentsLabel.text = @"";
+
+ int commentsToShow = 0;
+ for (PFObject *comment in comments)
+ {
+ if (commentsToShow < 5)
+ {
+ if (commentsToShow == 0)
+ {
+ cell.commentsLabel.text = [NSString stringWithFormat:@"%@: %@", [comment objectForKey:@"createdByUserName"], [comment objectForKey:@"text"]];
+ }
+ else
+ {
+ cell.commentsLabel.text = [NSString stringWithFormat:@"%@\n%@: %@", cell.commentsLabel.text, [comment objectForKey:@"createdByUserName"], [comment objectForKey:@"text"]];
+ }
+ commentsToShow++;
+ }
+ else
+ {
+ cell.commentsLabel.text = [NSString stringWithFormat:@"%@ ... (more)", cell.commentsLabel.text];
+ }
+ }
+
+ NSLog(@"%@", cell.commentsLabel.text);
+
+ cell.commentsLabel.backgroundColor = [UIColor yellowColor];
+ CGRect frame = cell.commentsLabel.frame;
+
+
+ frame.size.height = 15 * (commentsToShow);
+ cell.commentsLabel.frame = frame;
+
return cell;
}
-(void)viewDidAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:YES];
- [self loadObjects];
+
if (![PFUser currentUser])
{
@@ -107,6 +149,8 @@ -(void)viewDidAppear:(BOOL)animated
login.logInView.logo = label;
[self presentViewController:login animated:YES completion:nil];
}
+
+ [self loadObjects];
}
- (IBAction)onLikeButtonPressed:(UIButton*)button
{
@@ -116,7 +160,7 @@ - (IBAction)onLikeButtonPressed:(UIButton*)button
{
FeedTableViewCell *cell = (FeedTableViewCell*)[self.tableView cellForRowAtIndexPath:indexPath];
PFObject *photo = cell.photo;
- currentPhotoLikedByRelation = [photo relationforKey:@"following"];
+ currentPhotoLikedByRelation = [photo relationforKey:@"likedBy"];
if ([button.titleLabel.text isEqualToString:@"I Like this!"])
{
[currentPhotoLikedByRelation removeObject:currentUser];
@@ -137,8 +181,8 @@ - (IBAction)onCommentButtonPressed:(UIButton*)button {
{
selectedIP = indexPath;
-// FeedTableViewCell *cell = (FeedTableViewCell*)[self.tableView cellForRowAtIndexPath:indexPath];
-// PFObject *photo = cell.photo;
+ // FeedTableViewCell *cell = (FeedTableViewCell*)[self.tableView cellForRowAtIndexPath:indexPath];
+ // PFObject *photo = cell.photo;
}
}
@@ -146,10 +190,10 @@ -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"Comments"])
{
-
+
FeedTableViewCell *cell = (FeedTableViewCell*)[self.tableView cellForRowAtIndexPath:selectedIP];
PFObject *photo = cell.photo;
-
+
CommentTableViewController *vc = segue.destinationViewController;
vc.photo = photo;
@@ -175,7 +219,7 @@ -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
- return 440.0;
+ return 500.0;
}
@end