display NSDictionary to uilables dynamic view [closed] - ios

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
I have to parse a complicated xml
http://clinicaltrials.gov/show/NCT01423929?displayxml=true
in this xml when I change id NCT01423929 then i got another xml and both of xml tags are not fixed there may be change in number of tag according id.
But I have a an xml schema for above xml
http://clinicaltrials.gov/ct2/html/images/info/public.xsd
for parsing i am using XMLConverter and XMLReader both are return me NSDictionary but I don't get that how to dynamic work with NSDictionary to display keys on left side UILabel and value for that key on right side UILabel I am attached a screen that
Please help and sorry for bad english
Thanks in advance

It's pretty simple as you parse the data from xml.
Lets say your Dictionary name is parseDictionary and it's look something like below..
parseDictionary:
{
"Responsible Party" = "Gilead Sciences";
"Start Date" = "September, 2013";
"Last Updated Date" = "August 20, 2013";
}
You have already did that. Now just do the below
NSArray *keyArray=[parseDictionary allKeys];
for(NSString *key in keyArray)
{
[leftLabel setText:key]; //set the key on the leftLabel
[rightLabel setText:[parseDictionary objectForKey:key]]; //set the value on right label.
}
NB:: For each and every loop it'll over right the values so you will get only the Last Updated Date and August 20, 2013. I am just showing you how to get the key with associated value. I guess you must use UITableView to show the data. So there will no problem for you.

Related

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.

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];

Get latest inserted object FatFractal [closed]

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.

Parse this Json to NSmutablearray [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 9 years ago.
Improve this question
i've this unique text plain
{"id":"AALI.NG","data":["AALI","NG",19312,0,0,0,0,0,0,0,0,0,0,0,70,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"}
{"id":"AALI.RG","data":["AALI","RG",19500,0,0,0,0,0,0,0,0,0,0,0,26,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"}
{"id":"AALI.TN","data":["AALI","TN",19500,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"}
{"id":"ABBA.NG","data":["ABBA","NG",60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"}
{"id":"ABBA.RG","data":["ABBA","RG",85,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"}
{"id":"ABBA.TN","data":["ABBA","TN",85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"}
{"id":"ABDA.NG","data":["ABDA","NG",3500,0,0,0,0,0,0,0,0,0,0,0,6000,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"}
then i change it to :
{"stockQuote":[{"id":"AALI.NG","data":["AALI","NG",19312,0,0,0,0,0,0,0,0,0,0,0,70,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"},
{"id":"AALI.RG","data":["AALI","RG",19500,0,0,0,0,0,0,0,0,0,0,0,26,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"},
{"id":"AALI.TN","data":["AALI","TN",19500,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"},
{"id":"ABBA.NG","data":["ABBA","NG",60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"},
{"id":"ABBA.RG","data":["ABBA","RG",85,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"},
{"id":"ABBA.TN","data":["ABBA","TN",85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"},
{"id":"ABDA.NG","data":["ABDA","NG",3500,0,0,0,0,0,0,0,0,0,0,0,6000,0,0,0,0,0,0,0,0,0,0,0,0],"req":"SQ"}]}
basicly type of data i get from server is text/plain and i need to add {"stockQuote":[, "," and also }]} to make it like json...
the question is, how to parse it to json an NSMutableArray then i draw it to UITableView, how to do it?? should i change it to NSDictionary first and then insert it to NSMutableArray?
Your second JSON is just an NSDictionary with a single object that is an NSArray. So just take your normal array that you have in the first JSON, and do this:
NSArray *jsonArray = [jsonDic objectForKey:#"stockQuote"];
where jsonDic is your json's parse object with NSJSONSerialization method.

UIPickerView under empty selection [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
When my UIPickerView View is empty [the array is loads the data from is empty], If I try to select the Picker View the application crashes. What is the solution
I'm not sure but i guess that error generated because your array is empty and you should write any where in delegate method of UIPickerView such like [array objectAtindex....]; so,,
In each statement which you write [array objectAtindex....]; put condition that
if(array.count > 0)
[array objectAtindex....];..
So your picker will open but not generate any error.
EDITED:
I got solution for you:
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if ([myArray count] == 0)
return 1;
return [myArray count];
}
No need to apply any other condition i was checked it, in my project.
It's due to array out of bound exception it seems.
Check whether you are using any static index value while selecting the values.
e.g [sourceArray objectAtIndex:0]; // It get crash when the source array is empty.

Resources