0

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?

9
  • Your array contains only four items chapterno, verses, genisis and text? Commented Sep 30, 2011 at 6:37
  • chapterno, verses, genisis and text are arrays? Commented 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. Commented Sep 30, 2011 at 6:51
  • @RahulSharma these are four colomns in the databse that i have fetched in array Commented 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). Commented Sep 30, 2011 at 6:58

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

got the first verse of the bible,but i need to display alla the verses in the textview sir.thanks.
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?
sir got the answer,i put @" " instead of /n.thanks for ur help
i have another doubt,if u r free please help me to solve this here is my question [link]: stackoverflow.com/questions/7631597/…
0

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

@Nitish, It seems the bibleArray has objects of type bible. More structured/object-oriented than a dictionary ;-)
@EmptyStack : Your implementation is correct too :) Its just I use dictionaries instead ;)
@EmptyStack : +1 for your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.