Get latest inserted object FatFractal [closed] - ios

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm using FatFractal for my backend in a iPhone-app. Been searching the web and FatFractal docs without any luck.
I want to retrieve the latest object in a collection from a grabbag:
NSArray *result = [[Store ff] grabBagGetAllForObj:thread grabBagName:#"messages" withQuery:#"Get the latest inserted object" error:&err];

Probably the best way to do this is to construct the full query yourself and then use the standard getArrayFromUri: method. Taking your example, this would look like:
FatFractal *ff = [Store ff];
NSString *query = [NSString stringWithFormat:
#"%#/messages?sort=createdAt desc&start=0&count=1",
[ff metaDataForObj:thread].ffUrl];
NSArray *result = [ff getArrayFromUri:query];
For more info, see http://fatfractal.com/prod/docs/queries/#sorting-and-limiting-results.

Related

NSString key for value [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
NSString *userUpdate = [NSString stringWithFormat:#"grant_type=password&Password=%#&UserName=%#&SchoolId=1",[params valueForKey:#"UserName"#"Password"]];
When I am running this code I am getting an error. Is this code correct?
The problem in your code is you have written %# twice and supplied only single value, that is the main reason behind error.
In NSDictionary you can get only one value at a the time using valueForKey.
Use this code
NSString *userUpdate = [NSString stringWithFormat:#"grant_type=password&Password=%#&UserName=%#&SchoolId=1",[params valueForKey:#"Password"],[params valueForKey:#"UserName"]];
In NSDictionary Get only one value using valueForKey.
For Getting Password access like [params valueForKey:#"Password"]
For UserName use syntax like [params valueForKey:#"UserName"]
Can't get both value same time use like [params valueForKey:#"UserName"#"Password"]
Below is sample code:
NSString *userUpdate = [NSString stringWithFormat:#"grant_type=password&Password=%#&UserName=%#&SchoolId=1",[params valueForKey:#"Password"],[params valueForKey:#"UserName"]];

How to create a simple API in Firebase? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have never worked on the backend and never created an API, all I know is to handle the JSON response, This doesn't help much, but I do not understand "PUT - Writing Data".
However, I just want to know that how can I create a simple dictionary of multiple arrays or key-values as rest API, So that it can be fetched and i can show the data in table view etc.
According to Firebase Documentations, if you wanna create a node on Firebase realtime database, you can simply set a value to any key you want. The value here should be NSDictionary.
This is the code you can refer to:
// create a new node
[[[_ref child:#"users"] child:user.uid] setValue:#{#"username": username}];
// you can also use update to create a new node
NSString *key = [[_ref child:#"posts"] childByAutoId].key;
NSDictionary *post = #{#"uid": userID,
#"author": username,
#"title": title,
#"body": body};
NSDictionary *childUpdates = #{[#"/posts/" stringByAppendingString:key]: post,
[NSString stringWithFormat:#"/user-posts/%#/%#/", userID, key]: post};
[_ref updateChildValues:childUpdates];
Hope it helps.

save string variable in NSMutableArray -Error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm new to iOS and its development. Here I'm passing string value to saveStringpath variable then I want to save it in type NSMutable array saveStrings but I'm getting:
thread 1 exc_bad_access (code=2 type breakspoint
please help me.
//here i need to save these data in NSMutable array
-(void)saveNSMutablearray:(NSString*)saveStringpath
{
//start Mutable array to save this values
NSMutableArray *saveStrings =[[NSMutableArray alloc]init];
[saveStrings addObject:saveStrings];
NSString *test = [saveStrings objectAtIndex:0];
NSLog(#"JSON:-----vm %#", test);
}
The problem you are facing is because of wrong variable name. In your code you are adding array into array, so to solve the problem please change this line:
[saveStrings addObject:saveStrings];
into that one:
[saveStrings addObject:saveStringpath];
and the problem is gone :)

Combining arrays into a url string [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
So I'm building an array of url strings using extensions. I have two arrays of extensions and Im a little bit confused on how to combine them.
I am trying to produce an array of string objects with the following format:
http://mywebsite.com/images/places/extention1/extention1
http://mywebsite.com/images/places/extention2/extention2
and so on...
When I try to combine them the way I know how I end up with the full array stuck in the place holders
http://mywebsite.com/images/places/full array1/full array 2
but what I'm really trying to do is build an array of those URL strings from the other two arrays
i know this is super simple but I haven't found any documentation on combining them into a skeleton string.
This would do the trick:
NSMutableArray *urlArray = [[NSMutableArray alloc] init];
NSArray *extensions = #[#"extension1", #"extension2", #"extension3"];
NSString *urlString = #"http://mywebsite.com/images/places/";
for (NSString *extension in extensions) {
NSString *combined = [[urlString stringByAppendingPathComponent:extension] stringByAppendingPathComponent:extension];
[urlArray addObject:combined];
}
There are tons of ways to do this but it could be as simple as:
NSArray *array = [NSArray arrayWithObjects:#"http://mywebsite.com/images/places/extention1/extention1", #"http://mywebsite.com/images/places/extention1/extention2", nil];

nsmutablearray addobject adding object.text twice [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Using addObject is adding the object twice
AppDelegate *appdelegate = [[UIApplication sharedApplication] delegate];
NSLog(#"LOG1 %#", object.text);
[appdelegate.mutarray addObject:object.text];
NSLog(#"LOG2 %#", appdelegate.mutarray);
Log1 returns: LOG1 value
Log2 returns: LOG2 (
"value",
"value"
)
why is it adding in twice? removeObject removes both can i remove just one
Because your first time added your value to NSMutableArray through without remove value from the NSMutableArray going add often. that so far it be adding concurrent duplicate value. before adding new value remove your entire array.
if(appdelegate.mutarray.count!=0)
[appdelegate.mutarray removeAllObject];
[appdelegate.mutarray addObject:object.text];

Resources