Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6223945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:34:47+00:00 2026-05-24T08:34:47+00:00

I Create a class named DataClass there i have this method +(NSMutableArray*) returnList :(NSString

  • 0

I Create a class named DataClass there i have this method

+(NSMutableArray*) returnList :(NSString *) sql
{

    NSMutableArray *tmpList=[[[NSMutableArray alloc]init]autorelease];

    sqlite3 *db;

    NSString *dbPath =[[NSBundle mainBundle] pathForResource:@"DB_MyReef" ofType:@"sqlite"];


    if (sqlite3_open([dbPath UTF8String],&db) ==SQLITE_OK)
    {

        sqlite3_stmt *ss;

        int rv = sqlite3_prepare_v2(db, [sql UTF8String], -1,&ss,NULL);

        if (rv==SQLITE_OK)
        {

            while (sqlite3_step(ss)==SQLITE_ROW) 
            {

                NSString *txt =[NSString stringWithUTF8String:(char *)sqlite3_column_text(ss,0)]; 
                [tmpList addObject:txt];
                [txt release];

            }
        }

        sqlite3_finalize(ss);
    }

    sqlite3_close(db);


    return tmpList; 


}

In my other class named UserSelect i create.

in h file

@interface UserSelect : UIViewController <UIPickerViewDelegate,UIPickerViewDataSource> {

    NSMutableArray *List;
    UIPickerView *myPicker; 

}

@property (nonatomic,retain) NSMutableArray *List;
@property (nonatomic,retain) UIPickerView *myPicker;


@end

and m file

- (void)viewDidLoad {



    [super viewDidLoad];

    //List=[[NSMutableArray alloc] init;

    NSString *sql;
        //Loading Data
        if ([self.title isEqualToString:@"Marca Teste"]) 
        {
            sql=@"SELECT TESTMARK FROM TBL_TESTSMARK ORDER BY TESTMARK";
        }
        else
        {
            sql=@"SELECT PT_PARAMNAME FROM TBL_PARAMETERS "
            "WHERE COD IN "
            "(SELECT A.CODTEST FROM TBL_TEST AS A  "
            "INNER JOIN  "
            "TBL_TESTSMARK AS B "
            "ON  "
            "A.CODTESTMARK =B.COD "
            "WHERE " 
            "B.TESTMARK='Salifert')";
        }

    self.List=[[NSMutableArray alloc] init];
    self.List=[[NSMutableArray arrayWithArray:[DataClass returnList:sql]]retain];

    myPicker=[[UIPickerView alloc] init];
    myPicker.delegate=self;
    myPicker.dataSource=self;

        /*for (NSString *ts in List) {
            NSLog(@"%@",ts);
        }*/

        [self.view addSubview:myPicker];    


    }

Ok, i call this method and this return is a expected.

But in the UiPickerView methods my List variable only retain the first object in the NSMutable array.

These are the UIPicker methods

#pragma mark pickerView

-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    NSLog(@"%@",@"numberOfComponentsInPickerView");
    return 1;
}

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    NSLog(@"%@",@"numberOfRowsInComponent");

    return [List count];
}


-(NSString *)pickerView:(UIPickerView *) pickerView titleForRow:(NSInteger) row forComponent:(NSInteger) component
{
    NSString *txt=[[NSString alloc] initWithFormat:@"%@",[self.List objectAtIndex:(int)row]];
    return txt;
    [txt release];
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    NSString *txt=[[NSString alloc] initWithFormat:@"%@",[self.List objectAtIndex:(int)row]];

    [DataClass writePlist:txt toKey:TEST_MARK]; 

    [txt release];


}

I tried to boot List in many ways, what`s wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:34:51+00:00Added an answer on May 24, 2026 at 8:34 am

    Take a look here:

    NSString *txt =[NSString stringWithUTF8String:(char *)sqlite3_column_text(ss,0)]; 
    [tmpList addObject:txt];
    [txt release];
    

    The string txt is autoreleased (NSString stringXXX functions return an autoreleased string). Then you add it to the tmpList and explicitly release it. As soon as the autorelease pool is drained, the string will be released. In other words, you over-release the string. Remove

    [txt release];
    

    and the values should be retained by tmpList. Since tmpList is autoreleased too, it is not sure if this matters. It could give you a runtime error.

    This is also suspicious:

    self.List=[[NSMutableArray alloc] init];
    self.List=[[NSMutableArray arrayWithArray:[DataClass returnList:sql]]retain];
    

    The first alloc-init is totally unnecessary. If the property was synthesized properly, it will not produce a leak, but it doesn’t make any sense. Remove the first of these two lines.

    Also, your returnList: method returns a string, but you use it as array in the second line I quoted above.

    All in all, there are quite a few logical errors in your code. You might want to run it through the debugger and the analyzer (menu Product – Analyze).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have create a Class named EngDictionary. and Then i define a dictionary in
I have created a class named Times and I have to construct 4 overloaded
I have a class named Person with multiple properties, for example: public class Person
I have a custom class named BlinkingLight. I also have a static ObservableCollection BlinkingLightCollection.
In Java i have abstract class named Operation and three its subclasses called OperationActivation,
I have a scenario where i want : To create a data class which
I have a LINQ to SQL class called Data with a column of type
I have a class named MyCart. Class MyCartClass { var $MyCart; function getCart(){ return
I have a class named NodeUtil and that class have a three services injected
I want to create an alias for a class name. The following syntax would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.