UIViewController 内でコメント UITableView を作成しようとしていますが、問題が発生しています。テキストを直接設定すると (cell.username.text) 表示されますが、PFQuery (parse.com) で入力しようとすると何も表示されません
//DetailViewController.h
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface DetailViewController : UIViewController{
}
@property (strong, nonatomic) PFObject *place;
@property (strong, nonatomic) IBOutlet PFImageView *userPhoto;
@property (strong, nonatomic) IBOutlet UILabel *username;
@property (strong, nonatomic) IBOutlet UILabel *message;
@property (strong, nonatomic) IBOutlet UILabel *distance;
@property (strong, nonatomic) IBOutlet UILabel *checkCount;
@property (strong, nonatomic) IBOutlet PFImageView *photo;
@property (strong, nonatomic) IBOutlet UIScrollView *scroller;
@property (strong, nonatomic) IBOutlet UITableView *commentsTableView;
- (IBAction)checkMarkButton:(UIButton *)sender;
@end
//DetailViewController.m
#import "DetailViewController.h"
#import "CommentsViewController.h"
@interface DetailViewController (){
CommentsViewController *test;
}
@end
@implementation DetailViewController
@synthesize place;
@synthesize userPhoto, message, username, checkCount, photo, scroller, commentsTableView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
test = [[CommentsViewController alloc] init];
self.commentsTableView.delegate = test;
self.commentsTableView.dataSource = test;
[test commentsQuery:place];
}
//CommentsViewController.h
#import <Parse/Parse.h>
@interface CommentsViewController : UITableViewController{
}
@property (strong, nonatomic) PFObject *place;
- (void)commentsQuery:(PFObject *)object;
@end
//CommentsViewController.m
#import "CommentsViewController.h"
#import "DetailViewController.h"
#import "CommentsCell.h"
@interface CommentsViewController (){
NSArray *commentsArray;
}
@end
@implementation CommentsViewController
@synthesize place;
- (void)commentsQuery:(PFObject *)object {
place = object;
PFQuery *query1 = [PFQuery queryWithClassName:@"activity"];
[query1 whereKey:@"type" equalTo:@"comment"];
[query1 whereKey:@"place" equalTo:place];
[query1 orderByDescending:@"createdAt"];
[query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error){
commentsArray = [[NSArray alloc]initWithArray:objects];
NSLog(@"%lu", (unsigned long)[commentsArray count]);
}
}];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [commentsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *CellIdentifier = @"Cell";
CommentsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[CommentsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
PFObject *tempObj = [commentsArray objectAtIndex:indexPath.row];
cell.username.text = @"username";
cell.comment.text = [tempObj objectForKey:@"content"];
cell.userThumbnail.file = [tempObj objectForKey:@"userThumbnail"];
[cell.userThumbnail loadInBackground];
return cell;
}
@end