Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed to pull facebook IDs from array of "friendUsers" and query Facebook for their names or profile pictures
    primarykey
    data
    text
    <p>I'm doing this in kind of a roundabout way. I'm pulling users who are current users of my app as well as Facebook friends with the current user.</p> <p>When you print friendUsers [which is an array] you get this:</p> <pre><code>"&lt;PFUser:1234567:(null)&gt; {\n fbId = abcdefg;\n username = ausername;\n}" ) </code></pre> <p>I obviously swapped out some of the info for simplicity, but you get the idea.</p> <p>So if I have an array of a lot of users, I'll want to pull the fbId, and query facebook and get their profile pic to display in a table. Then you can just tap their profile pic. The idea is to change who the object is assigned to. </p> <p>I'm getting an incompatible pointer to integer conversion sending NSIndexPath strong to parameter of type NSUInteger in <code>didSelectRowAtIndexPath</code>. </p> <p>Not only that, but I realize here I'm just selecting the one user here:</p> <pre><code>PFUser *facebookID = [[PFUser alloc] init]; facebookID = [friendUsers objectAtIndex:0]; </code></pre> <p>That's because at the moment I only have one other user that has my app installed. I was just doing this to see if my app was working when querying Facebook. It is but, how would I grab all of the facebookIDs if there's lots of users?</p> <pre><code>#import "FacebookFriendViewController.h" #import "MainQueryViewController.h" #import &lt;Parse/Parse.h&gt; @interface FacebookFriendViewController () @end @implementation FacebookFriendViewController @synthesize friendUsers; @synthesize pic; @synthesize object; - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"This is what was passed to the view controller."); NSLog(@"Printing friendUsers: %@", friendUsers); NSLog(@"%@", object); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { #warning Potentially incomplete method implementation. // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"The count is... count=%d",[friendUsers count]); // Return the number of rows in the section. return [friendUsers count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"friendCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; PFUser *facebookID = [[PFUser alloc] init]; facebookID = [friendUsers objectAtIndex:0]; NSString *fbIdString = [[NSString alloc] init]; fbIdString = [facebookID objectForKey:@"fbId"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } NSLog(@"This is a facebook ID:%@", fbIdString); NSURL *profilePictureURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large", fbIdString]]; NSData *picData = [NSData dataWithContentsOfURL:profilePictureURL]; UIImageView *fbPic = (UIImageView *)[self.view viewWithTag:1001]; [fbPic setImage:[UIImage imageWithData:picData]]; // Configure the cell... return cell; } #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [object setObject:[friendUsers objectAtIndex:indexPath] forKey:@"assignedTo"]; } @end </code></pre> <p>Thanks for your help</p> <p><strong>UPDATE</strong></p> <p>Per HRM's inquiry, here is what is sent to the friend picker view.</p> <pre><code> PF_FBRequest *request = [PF_FBRequest requestForMyFriends]; [request startWithCompletionHandler:^(PF_FBRequestConnection *connection, id result, NSError *error) { if (!error) { // result will contain an array with your user's friends in the "data" key NSArray *friendObjects = [result objectForKey:@"data"]; NSMutableArray *friendIds = [NSMutableArray arrayWithCapacity:friendObjects.count]; // Create a list of friends' Facebook IDs for (NSDictionary *friendObject in friendObjects) { [friendIds addObject:[friendObject objectForKey:@"id"]]; } // Construct a PFUser query that will find friends whose facebook ids // are contained in the current user's friend list. PFQuery *friendQuery = [PFUser query]; [friendQuery whereKey:@"fbId" containedIn:friendIds]; // findObjects will return a list of PFUsers that are friends // with the current user NSArray *friendUsers = [friendQuery findObjects]; NSLog(@"%@", friendUsers); [self performSegueWithIdentifier:@"sendToFriend" sender:friendUsers]; } }]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload