I have an arrayappdeligate.biblearray. I just want to display this array in a textview. This array contains sql datas of 4 types chapterno, verses, genisis and text. i need to extract only the verses and display it in textview how to do this?
-
Your array contains only four items chapterno, verses, genisis and text?EmptyStack– EmptyStack2011-09-30 06:37:33 +00:00Commented Sep 30, 2011 at 6:37
-
chapterno, verses, genisis and text are arrays?EmptyStack– EmptyStack2011-09-30 06:48:06 +00:00Commented Sep 30, 2011 at 6:48
-
how have you added chapterno, verses, genisis and text in array ?. Do you mean that these are the four columns in database that you have fetched in an array.Rahul Sharma– Rahul Sharma2011-09-30 06:51:14 +00:00Commented Sep 30, 2011 at 6:51
-
@RahulSharma these are four colomns in the databse that i have fetched in arrayNipsApp Game Studios– NipsApp Game Studios2011-09-30 06:52:37 +00:00Commented Sep 30, 2011 at 6:52
-
@Nipinvarma your way is not correct, array should have entities and access column value same as property or using key(column name).Ishu– Ishu2011-09-30 06:58:49 +00:00Commented Sep 30, 2011 at 6:58
|
Show 4 more comments
2 Answers
It seems biblearray has the objects of type bible. You can get the verses from bible objects like this,
bible *_bible = (bible *)[appDelegate.bibleArray objectAtIndex:0];
textView.text = [_bible verses];
or directly as,
textView.text = [[appDelegate.bibleArray objectAtIndex:0] verses];
If you want to display all the verses in the textView, you can do it like this,
NSArray *allVerses = [appDelegate.bibleArray valueForKey:@"verses"];
textView.text = [allVerses componentsJoinedByString:@"\n\n"];
@"\n\n" adds two new lines between the verses.
4 Comments
NipsApp Game Studios
got the first verse of the bible,but i need to display alla the verses in the textview sir.thanks.
NipsApp Game Studios
ohhh thats awsomeee,i got alla the verses ,but just one more help i have to separate it with space not the /n .is it possible?
NipsApp Game Studios
sir got the answer,i put @" " instead of /n.thanks for ur help
NipsApp Game Studios
i have another doubt,if u r free please help me to solve this here is my question [link]: stackoverflow.com/questions/7631597/…
You need to do some alteration. Create NSDisctionary instead.
Take a dictionary where you are adding data from database
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
NSMutableArray *chapterno = [[NSMutableArray alloc]init];
NSMutableArray *verses = [[NSMutableArray alloc]init];
NSMutableArray *genisis = [[NSMutableArray alloc]init];
NSMutableArray *text = [[NSMutableArray alloc]init];
//Add data you are getting from database
[chapterno addObject:chapternodata];
[verses addObject:versesdata];
[genisis addObject:genisisdata];
[text addObject:textdata];
[dict setValue:chapterno forKey:@"chapterno"];
[dict setValue:verses forKey:@"verses"];
[dict setValue:genisis forKey:@"genisis"];
[dict setValue:text forKey:@"text"];
[chapterno release];
[verses release];
[genisis release];
[text release];
Take one NSDictionary in AppDelegate say appDict and make it equal to dict
NSMutableArray *arrVerses = [[objAppDel.appDict objectForKey:@"verses"];
txt.text = [arrVerses description];
3 Comments
EmptyStack
@Nitish, It seems the
bibleArray has objects of type bible. More structured/object-oriented than a dictionary ;-)Nitish
@EmptyStack : Your implementation is correct too :) Its just I use dictionaries instead ;)
Nitish
@EmptyStack : +1 for your answer.