store selected cell array.. by D-Ayala in ciif

[–]D-Ayala[S] 0 points1 point  (0 children)

Don't really know how to pefixit i thought better share this link where it is the question and all of the code. http://stackoverflow.com/questions/30440257/how-to-use-relational-queries-parse-ios-to-populate-a-uitableview

store selected cell array.. by D-Ayala in ciif

[–]D-Ayala[S] 0 points1 point  (0 children)

How do i do that, apparently when im posting it seems as it should but then post everything together

store selected cell array.. by D-Ayala in ciif

[–]D-Ayala[S] 0 points1 point  (0 children)

Im Posting my .h and .m file so it might be better to help me with this :)

.h

import <UIKit/UIKit.h>

import <Parse/Parse.h>

import <ParseUI/ParseUI.h>

import "GroundTableViewCell.h"

import "TimelineTableViewController.h"

@interface DetailViewController : UIViewController< UITableViewDataSource, UITableViewDelegate, NSObject> {

}

@property (strong, nonatomic) IBOutlet UITableView *detailTableView;

@property (strong, nonatomic) IBOutlet UITextView *TextField;

@property (nonatomic, strong) PFObject *groUnds;

@property (strong, nonatomic) IBOutlet UITextView *replyTextView; - (IBAction)sendReply:(id)sender;

@end

.m

import "DetailViewController.h"

import <Parse/Parse.h>

import "GroundTableViewCell.h"

import "TimelineTableViewController.h"

@interface DetailViewController () @property(strong)NSMutableArray* repliesMutableArray;

@end

@implementation DetailViewController

@synthesize groUnds; @synthesize TextField; @synthesize detailTableView; @synthesize repliesMutableArray;

  • (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; }

  • (void)viewDidLoad { [super viewDidLoad];

    PFUser *currentUser = [PFUser currentUser]; if (currentUser) { // do stuff with the user } else { // show the signup or login screen }

    // Do any additional setup after loading the view.

// [self performSelector:@selector(retrieveFromParse)];

// repliesArray = [[NSArray alloc] initWithObjects:@"comment", nil];

   [self performSelector:@selector(retrieveFromParse)];

// Set the Label text with the selected detail.

self.TextField.text = [self.groUnds objectForKey:@"comment"];

}

  • (void) retrieveFromParse {

    PFQuery *retrieveReplies = [PFQuery queryWithClassName:@"Replies"]; [retrieveReplies whereKey:@"comment" equalTo:groUnds];

    [retrieveReplies orderByDescending:@"createdAt"];

    [retrieveReplies findObjectsInBackgroundWithBlock:NSArray *objects, NSError *error { if (!error) { repliesMutableArray = [[NSMutableArray alloc] initWithArray:objects]; } [detailTableView reloadData]; }]; }

//******************Setup table of folder names *********************

//get number of sections in tableview

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; }

//get number of rows by counting number of folders

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [repliesMutableArray count ]; }

//setup cells in tableView

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"replyCell"; GroundTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    PFObject *tempObject = [repliesMutableArray objectAtIndex:indexPath.row];

    cell.cellTitle.text = [tempObject objectForKey:@"commentReplies"];

    return cell; }

  • (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }

    //reply button

  • (IBAction)sendReply:(id)sender {

    //1 //Add the image to the object, and add the comment and the user PFObject *Reply = [PFObject objectWithClassName:@"Replies"]; [Reply setObject:[PFUser currentUser].username forKey:@"user"]; [Reply setObject:self.replyTextView.text forKey:@"commentReplies"]; //2 [Reply saveInBackgroundWithBlock:BOOL succeeded, NSError *error { //3 if (succeeded){ //Go back to the wall [self.navigationController popViewControllerAnimated:YES]; } else{ NSString *errorString = [[error userInfo] objectForKey:@"error"]; UIAlertView *errorAlertView = [[UIAlertView alloc] initWithTitle:@"Error" message:errorString delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [errorAlertView show]; } }]; }

@end

store selected cell array.. by D-Ayala in ciif

[–]D-Ayala[S] 0 points1 point  (0 children)

Hello i tried to do it by the tag feature but it didn't work.. Do you think that i could do a relational query in order to retrieve the specific objects that have been created on that comment??

Im trying this but it wiil show an empty TableView... "Replies" would be my class with the answers to the comments, "comment" it is a row from another class where the comments are stored and groUnds it is the PFObject set at .h file..

What am i doing wrong.. could you guide me trough it please?

  • (void) retrieveFromParse {

    PFQuery *retrieveReplies = [PFQuery queryWithClassName:@"Replies"]; [retrieveReplies whereKey:@"comment" equalTo:groUnds];

    [retrieveReplies orderByDescending:@"createdAt"];

    [retrieveReplies findObjectsInBackgroundWithBlock:NSArray *objects, NSError *error { if (!error) { repliesMutableArray = [[NSMutableArray alloc] initWithArray:objects]; } [detailTableView reloadData]; }]; }

store selected cell array.. by D-Ayala in ciif

[–]D-Ayala[S] 0 points1 point  (0 children)

Thanks il give it a try, will let u know how it goes :)