0

1) How to add sqlite database values into an array. 2) I was retrived my sqlite database values but how can I put these values into an array for to show the another viewcontroller tableview. 3) What can I write in viewcontroller.h and viewcontroller.m . 4) Below one I wrote but it getting error "No known class method for selector'getData'"

Code:

 - (void)viewDidLoad
    {

    [super viewDidLoad];

   depositArray=[[NSMutableArray alloc]init];
    depositData=[[NSMutableArray alloc]init];
    depositArray=[dbModelClass getData:str];

    for( NSDictionary *dis in depositArray)
    {
        [depositData addObject:[dis objectForKey:@"depositTable"]];
    }
rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2420691
  • 15
  • 1
  • 3
  • Well, what type is dbModelClass declared to be? Presumably not a class that defines a `getData:` method. (Or, if it's really saying "No known CLASS method" then I suspect that "dbModelClass" is a class name, and `getData:` is an instance method (ie, `-` vs `+`).) – Hot Licks Jun 05 '13 at 15:59
  • Looking at your [other question](http://stackoverflow.com/questions/16937468/how-to-add-sqlite-database-values-into-an-array-and-how-to-add-these-values-into), I see that "dbModelClass" is a class name, and it has a class method named `getData`. Note that `getData` is NOT the same as `getData:`. – Hot Licks Jun 05 '13 at 16:05
  • (And please learn standard C/C++/Objective-C/Java naming conventions: Class names should begin with a capital letter, and the names of fields and methods and local variables should begin with a lower-case letter.) – Hot Licks Jun 05 '13 at 16:06
  • 1
    (You need to purchase a good tutorial on iPhone programming and study it. You can't learn the language simply by blindly copying examples you find on the net.) – Hot Licks Jun 05 '13 at 16:07

1 Answers1

0

Did you #import the header that declares the incorrectly named getData: method?

Note: If you are writing raw SQL, you are wasting your time. Use FMDB (or similar) if you need database portability beyond iOS/OS X. If you are targeting only iOS / OS X, then Core Data is an excellent solution that has a very tight integration with the system.


Some other issues:

This makes no sense:

 depositArray=[[NSMutableArray alloc]init];
 depositArray=[dbModelClass getData:str];

The first line allocates an array. The second line immediately assigns a new value to the variable pointing to that original array, both losing the reference to it and leaking memory.

Also, methods should not be prefixed with get. That is reserved for very specific use cases.

bbum
  • 162,346
  • 23
  • 271
  • 359