I have an object called masterMessages filled with objects called messages. Each message object has five keys:
objectId
senderId
senderName
messageBody
timestamp
Basically what I am doing now is querying all the messages sent to my user in this object called masterMessages. Then i'm using:
self.senderIds = [masterMessages valueForKeyPath:#"#distinctUnionOfObjects.senderId"];
to get all the different sender ids (senderId) in an array called senderIds. With this I will populate my conversations table. But i want to populate it with the sender names (senderName) and not the senderIds. I only do it this way in case two users have the same name.
I am trying to find:
How do I say "get valueForKey:#"senderName" for this senderId
and
is there a better way to populate my conversations table?
Here is my code:
note: im using parse.com
-(void)viewWillAppear:(BOOL)animated{
NSString *userId = [[PFUser currentUser] objectId];
PFQuery *query = [PFQuery queryWithClassName:#"lean"];
[query whereKey:#"recipientId" equalTo:userId];
[query orderByDescending:#"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
else {
// We found messages!
masterMessages = objects;
NSLog(#"self.messages = %#", masterMessages);
self.senderIds = [masterMessages valueForKeyPath:#"#distinctUnionOfObjects.senderId"];
NSLog(#"self.senderIds = %#", self.senderIds);
[self.tableView reloadData];
}
}];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [self.senderIds count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
NSLog(#"self.senderIds = %#", self.senderIds);
NSString *senderDisplayName = [self.senderIds objectAtIndex:indexPath.row];
NSLog(#"sender = %#", senderDisplayName);
cell.textLabel.text = senderDisplayName;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
selectedId = [self.senderIds objectAtIndex:indexPath.row];
[self performSegueWithIdentifier:#"ShowMissionMessage" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"ShowMissionMessage"]) {
[segue.destinationViewController setHidesBottomBarWhenPushed:YES];
MissionChat *missionchatviewcontroller = (MissionChat *)segue.destinationViewController;
missionchatviewcontroller.selectedId = selectedId;
missionchatviewcontroller.masterMessages = masterMessages;
}
}
There are a few issues in the question, one is how to dereference PFObjects, which we took care of on another thread. The rest of this question is about (a) how to use parse objects to build a datasource to support a tableview, and a harder one (b) how to get information from related objects.
Starting with (b), the harder one: There are a few ways to relate objects. Your choice a string-typed column containing the related object id, is intuitive (especially if you have an SQL background), but the least advisable. The better (best) way to model a one-to-one or small one-to-many relation is with a pointer (or array of pointers if one-to-many).
So I think your senderId and recipientId string columns should be replaced by pointer-typed columns called sender and recipient. The huge advantage of this is the ability to eagerly fetch those pointed-to objects on the message (or "lean" in your terms) query.
Having made that change, you're new improved query looks like this:
PFQuery *query = [PFQuery queryWithClassName:#"lean"];
// notice the first change for the better here:
[query whereKey:#"recipient" equalTo:[PFUser currentUser]];
[query orderByDescending:#"createdAt"];
// notice the really valuable feature here:
[query includeKey:#"sender"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
// using the array of PFObjects understanding from your other question...
for (PFObject *pfObject in objects) {
NSString *messageBody = [pfObject objectForKey:#"messageBody"];
// these lines here are the punch line:
PFUser *sender = [pfObject objectForKey:#"sender"];
NSString *senderName = [sender username];
NSLog(#"The message %# was sent by %#", messageBody, senderName);
}
}];
The important thing to notice above is that we were able to ask resulting objects for the #"sender" column, and, because you've changed it to a pointer, and because you've done an includeKey on the query, that complete object (e.g. including the PFUser username) is now fetched.
Now the easy question (a). Now that you have the data right from the server, the datasource for the table is nothing more than the returned objects. In other words, throw away the the senderIds array and replace it with:
#property(nonatomic, strong) NSArray *messages;
Your find block becomes trivial:
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
self.messages = objects;
}];
Answer messages.count for numberOfRowsInSection, and then pick what you need from the objects in cellForRowAtIndexPath...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
PFObject *message = self.messages[indexPath.row];
NSString *messageBody = [message objectForKey:#"messageBody"];
PFUser *sender = [message objectForKey:#"sender"];
NSString *senderName = [sender username];
cell.textLabel.text = senderName;
return cell;
}
function findObjectByKey(array, key, value) {
for (var i = 0; i < array.length; i++) {
if (array[i][key] === value) {
return array[i];
}
}
return null;
}
var obj = findObjectByKey(objArray, 'id', 3);
//ES6
var obj = objArray.find(function (obj) { return obj.id === 3; });
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else if (i == key && obj[key] == val) {
objects.push(obj);
}
}
return objects;
}
var result = getObjects(obj, 'category_id', valu.category_id);
console.log(result);
Related
I am working on a app that you can change when a item on the menu is in stock or out of stock.
I have it now so it changes the UISwitch to on or off when it loads the screen. I need each switch to change a NSString in parse that makes it one or zero.One meaning that it is on zero meaning its off.
I am fairly new to objective c and parse so if any one could help me get a start on this problem that would be great!
You might use something like that:
PFQuery *query = [PFQuery queryWithClassName:#"YourClass"];
[query whereKey:#"user" equalTo:[PFUser currentUser]];
[query getFirstObjectInBackgroundWithBlock:^(PFObject * yourClass, NSError *error) {
if (!error) {
// Found yourClass object
[yourClass setObject:isInStock forKey:#"isInStock"];
// Save
[yourClass saveInBackground];
} else {
// Did not find any yourClass object for the current user
NSLog(#"Error: %#", error);
}
}];
NSArray *listObjects = .... (loading from Server) // List of PFObject
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
PFObject *object = [listObjects objectAtIndex:indexPath.row];
YourCell *cell = .....
if ([[object valueForKey:#"sandwichesOutofstock"] intValue] == 1)
cell.switch.on = true;
else
cell.switch.on = false;
cell.switch.tag = 500 + index.row;
[cell.switch addTarget:self action:#selector(switchTouch:) forControlEvents:UIControlEventTouchUpInside]
.........
}
(IBAction)switchTouch:(UISwitch *)switch{
long index = switch.tag - 500;
PFObject *object = [listObjects objectAtIndex:index];
if(switch.on)
[object setValue:#"1" ForKey:#"sandwichesOutofstock"];
else{
[object setValue:#"0" ForKey:#"sandwichesOutofstock"];
}
[object saveInBackground];
[self.tableView reloadRowsAtIndexPaths:[NSIndexPath indexPathForRow:index inSection:0] withRowAnimation:UITableViewRowAnimationNone];
}
You could assign a reference of the PFObject to the cell. Then when the switch changes just get the cell's object and make the change.
I am trying to populate a PFQueryTableViewController with Question objects from my Parse backend. How do I implement blocks within this method?
- (PFQuery *)queryForTable // I'm having issues with using the method "findObjectInBackgroundWithBlock" in this method.
{
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
[query fromLocalDatastore];
[query orderByDescending:#"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *parseQuestions, NSError *error) { // Fetch from local datastore
if (parseQuestions != nil) {
NSMutableArray *mutableParseQuestions = [parseQuestions mutableCopy];
self.questions = mutableParseQuestions; // if Set local array to fetched Parse questions
} else {
if ([InternetReachabilityManager isReachable]) {
[query findObjectsInBackgroundWithBlock:^(NSArray *parseQuestions, NSError *error) { // Fetch from Cloud
NSMutableArray *mutableParseQuestions = [parseQuestions mutableCopy];
self.questions = mutableParseQuestions; // if Set local array to fetched Parse questions
[Question pinAllInBackground:parseQuestions]; // Save query results to local datastore
}];
}
}
}];
return query;
}
When blocks are in this method I get this error.
Is this because queryForTable is already a background process? Should I just use
[query findObjects]
Also, I'm trying to implement reachability into my fetch.
Try fetching from local datastore
Load data into table if they are there else switch to the network
Call block if network is available
Save the results of the network fetch into the local datastore
I know that this method is supposed to automatically assign objects it fetches to rows but I don't know how to work with it if we're passing around a PFObject subclass object. This is my explanation for the arrays.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
self.question = [self.questions objectAtIndex:indexPath.row]; // Save one question from row
static NSString *identifier = #"QuestionsCell";
QuestionsCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[QuestionsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
[cell setQuestion:self.question]; //
return cell;
}
This is how I use the fetched array to populate the tableView.
So my questions:
Why can't I call a block inside of queryForTable?
Is there any way I can make this simpler by using queryForTable's automatic assigning of objects to rows?
If the internet is unreachable and the local datastore is empty what should I do?
There is no reason to call your query in that function. You're supposed to create a query and then return it. PFQueryTableViewController does the actual handling of the request. Read the documentation here: https://parse.com/docs/ios/api/Classes/PFQueryTableViewController.html#//api/name/queryForTable
Once you're in the cellForRowAtIndexPath method you can call objectAtIndexPath: which will you give you the object you need and then use the data from it to set up your cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
PFObject *object = [self objectAtIndexPath:indexPath];
UITableViewCell *cell = ....
//configure cell using object here
return cell;
}
You do this (semi-pseudo code)
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
if (self.objects.count == 0) {
Put some sort of overlay that shows there are no objects to be retrieved or internet is unreachable.
}
return self.objects.count;
}
This question already has an answer here:
Pass data from Parse tableview to WatchKit
(1 answer)
Closed 8 years ago.
I'm using Parse to create this table view, and am trying to figure out how to get the Parse table data into an array, so I can pass it into the WatchKit InterfaceController to show the exact same thing?
So I want to show in the WatchKit interface exactly what shows in the iPhone interface.
Here is what I have, let me know if I can add anything that would be helpful:
TableVC.m:
- (id)initWithCoder:(NSCoder *)aCoder
{
self = [super initWithCoder:aCoder];
if (self) {
self.parseClassName = #"na";
self.textKey = #"dateTime";
self.pullToRefreshEnabled = YES;
self.paginationEnabled = NO;
}
return self;
}
- (PFQuery *)queryForTable
{
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
return query;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
static NSString *simpleTableIdentifier = #"RecipeCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
UILabel *homeLabel = (UILabel*) [cell viewWithTag:101];
homeLabel.text = [object objectForKey:#"test"];
UILabel *dateLabel = (UILabel*) [cell viewWithTag:102];
dateLabel.text = [object objectForKey:#"dateTime"];
return cell;
}
Parse data:
TableVC.m:
I already have the basic WatchKit files and Storyboard set up. I hard coded an array to test that it was generally working. But now I just need to get the data from Parse into there, and not sure if I need to do a query and then turn that into a public array?
EDIT:
Here is my query:
PFQuery *query2 = [PFQuery queryWithClassName:#"nba"];
[query2 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// The find succeeded.
NSLog(#"Objects 2: %#", objects);
}
} else {
// Log details of the failure
NSLog(#"Error 2: %# %#", error, [error userInfo]);
}
}];
Here is my NSLog:
NSLog(#"Objects 2: %#", objects);
Console:
2015-02-09 21:06:30.845 SimpleTable[8373:1284663] Objects 2: (
"<na: 0x7ff3f8e40880, objectId: cOrjeAmwJh, localId: (null)> {\n away = Cav;\n date = \"04/19/2015\";\n dateTime = \"April 19, 2015, 16:00\";\n gNumber = 1;\n home = Bul;\n matup = \"Ca\";\n ro = \"Ro \";\n test = \"Test 2\";\n tv = T;\n}",
If you need the array, fetch it asynchronously in a method outside of the queryForTable method, get it like this:
PFQuery *query = [self queryForTable];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// objects is the array for this table
NSMutableArray *array = [#[] mutableCopy];
for (PFObject *object in objects) {
NSLog(#"we got an object with dateTime = %#", [object objectForKey:#"dateTime"]);
[array addObject:[object objectForKey:#"dateTime"]];
// you can prove this with any of your keys: away, number, home, mat up, etc.
}
}
}];
if you just want to pass the objects into an array you can do so like this or a variation of:
- (PFQuery *)queryForTable
{
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
self.someArray = [query findObjects];
return query;
}
REFERNECE
I have a parse app for iOS where it is sometimes necessary to search all the users. For some reason though, the users exist in the database but other users cannot see them in a search. I have seen no correlation between users or reason for this the only thing I'm thinking is maybe parse is not searching ALL users? Here is the code for the search
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.parseClassName = #"_User";
self.textKey = #"name";
// Whether the built-in pull-to-refresh is enabled
self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = NO;
}
return self;
}
- (PFQuery *)queryForTable
{
PFQuery *query = [PFQuery queryWithClassName:#"_User"];
[query whereKey:#"isTeacher" equalTo:#"True"];
[query whereKey:#"schoolName" equalTo:[[PFUser currentUser] objectForKey:#"schoolName"]];
return query;
}
I'm assuming if there was a problem it would be in the above, but the rest of the code is here if need be:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = #"Cell";
PFTableViewCell *cell = (PFTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.text = [object objectForKey:#"name"];
cell.detailTextLabel.text = [object objectForKey:#"username"];
}
// Configure the cell
if (tableView == self.tableView) {
cell.textLabel.text = [object objectForKey:#"name"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"Cell"];
}
}
if (tableView == self.searchDisplayController.searchResultsTableView) {
PFObject* object = self.searchResults[indexPath.row];
//UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell"];
cell.textLabel.text = [object objectForKey:#"name"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"Cell"];
}
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *teacherUsername = cell.textLabel.text
;
//NSLog(teacherUsername);
[[NSUserDefaults standardUserDefaults] setObject:teacherUsername forKey:#"teacherUsername"];
[self performSegueWithIdentifier:#"next" sender:self];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.tableView) {
return self.objects.count;
} else {
return self.searchResults.count;
}
}
-(void)filterResults:(NSString *)searchTerm {
[self.searchResults removeAllObjects];
PFQuery *query = [PFQuery queryWithClassName:#"_User"];
[query whereKey:#"isTeacher" equalTo:#"True"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
NSArray *results = [NSArray arrayWithArray:objects];
NSLog(#"%#", results);
NSLog(#"%lu", (unsigned long)results.count);
NSLog(#"results^");
[self.searchResults addObjectsFromArray:results];
NSPredicate *searchPredicate =
[NSPredicate predicateWithFormat:#"SELF.name contains[c] %#",searchTerm];
_searchResults = [NSMutableArray arrayWithArray:[results filteredArrayUsingPredicate:searchPredicate]];
[self.searchDisplayController.searchResultsTableView reloadData];
NSLog(#"%#", _searchResults);
NSLog(#"%lu", (unsigned long)_searchResults.count);
NSLog(#"search results^");
}];
}
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
[self filterResults:searchString];
return YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#end
Is there any reason why certain users would not show up? I have checked the obvious things, making sure the users have the same "schoolName" and "isTeacher" is true but I'm stumped. Attached is a screenshot of an example user in the parse core
The default limit for a Parse query is 100 objects so even though you expect 170 PFObjects, you need to specify that you want to receive 170+ objects from your query in order to receive them all from the query using the limit parameter, ex:
PFQuery *query = [PFQuery queryWithClassName:#"_User"];
[query whereKey:#"isTeacher" equalTo:#"True"];
[query setLimit: 1000]; // <-- increase the limit up to 1000
The upper limit for the number of PFObjects a PFQuery can return though is 1000, so since you have more than 1000 users and could hypothetically need to receive more than 1000 results when performing a different query, you can do so by looping through multiple queries while utilizing an increasing skip parameter, to specify the "number of objects to skip before returning any."
So whereas that first block of code I wrote will return the first 1000 objects from that query, the next 1000 can be retrieved like so:
PFQuery *query = [PFQuery queryWithClassName:#"_User"];
[query whereKey:#"isTeacher" equalTo:#"True"];
[query setLimit: 1000]; // <-- increase the limit up to 1000
[query setSkip: 1000]; // <-- skip the first 1000 already found
And generally speaking, although it's probably best to receive your results bit by bit and increment setSkip to receive more results only when you absolutely need them, you can hypothetically retrieve all the objects matching your query at once, like so:
- (void)theOriginalCallingMethod {
// Start out by fetching the maximum number of results
// from the query and start at the beginning, i.e.
// not skipping anything
[self performTeacherQueryWithLimit:1000 andSkip:0];
}
- (void)performTeacherQueryWithLimit:(int)limit andSkip:(int)skip {
PFQuery *query = [PFQuery queryWithClassName:#"_User"];
[query whereKey:#"isTeacher" equalTo:#"True"];
[query setLimit: limit];
[query setSkip: skip];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
// If the maximum number of objects is found, there
// may be more, so continue querying
if (objects.count == limit) {
// Perform the query using the same limit, but increase
// the skip amount by that current limit to indicate
// that the next query should skip the results we just
// found
[self performTeacherQueryWithLimit:limit andSkip:skip+limit];
}
// ...other code...
}];
}
Note: This will only work with a PFTableView as long as its paginationEnabled property is set to NO.
I am tying to display in my table view an array that is on a database on parse.com
I can display the first item in the array, but not the rest.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
_ListArray = [object objectForKey:#"content"];
NSLog(#"OBJECT = %#",_ListArray);
NSString *cellValue = [NSString stringWithFormat:#"%#", [_ListArray objectAtIndex:indexPath.row]];
cell.textLabel.text = cellValue;
if(refresh <counter)
{
NSString *br = #"<br>";
List = [NSString stringWithFormat:#"%#%#%#", List, br, cell.textLabel.text];
NSLog(#"%#",List);
refresh ++;
}
cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
If I try to use:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_ListArray count];
}
I get nothing in the table.
edit update:
did remove the self.ListArray and going with _ListArray.
in the h file:
NSMutableArray *ListArray;
...
#property (retain, atomic) NSMutableArray *ListArray;
and then in m file:
#synthesize ListArray = _ListArray;
regarding the:
self.ListArray = [object objectForKey:#"content"];
the object is the PFObject.
i have queryForTable where i get the data from parse.
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:#"List"];
[query whereKey:#"user" equalTo:[PFUser currentUser]]; // user
[query whereKey:#"objectId" equalTo:[theListID objectId]]; // the specific list
counter =[query countObjects];
NSLog(#"%d",counter);
// If Pull To Refresh is enabled, query against the network by default.
if (self.pullToRefreshEnabled) {
query.cachePolicy = kPFCachePolicyNetworkOnly;
}
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
if ([self.objects count] == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
[query orderByDescending:#"createdAt"];
return query;
}
And to the objectForKey:#"content"];
content is the name of the column in my class on parse
so i need to say what object from the class i want to get, and that is the array column named "content"
The logg, (when the NSLog is active on the array.
Inköpslista[7856:12e03] Warning: A long-running Parse operation is being executed on the main thread.
Break on warnParseOperationOnMainThread() to debug.
2013-10-21 14:23:31.008 Inköpslista[7856:12e03] 1
2013-10-21 14:23:31.017 Inköpslista[7856:12e03] OBJECT = (
"Br\U00f6d",
Anka,
Boll,
Sko
)
2013-10-21 14:23:31.017 Inköpslista[7856:12e03] <html><body><br>Bröd
2013-10-21 14:23:31.545 Inköpslista[7856:12e03] OBJECT = (
"Br\U00f6d",
Anka,
Boll,
Sko
)
Got it to work, did put the array were i get the data from parse, and then only call
cell.textLabel.text = [_ListArray objectAtIndex:indexPath.row];
and then i can use:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_ListArray count];
}