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 6846829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:40:17+00:00 2026-05-27T00:40:17+00:00

FOUND IT! (After 6 hours). Instead of deleting my question, I left it on

  • 0

FOUND IT! (After 6 hours).

Instead of deleting my question, I left it on in case someone else runs into the same problem.

Problem:

If I create an array with a fixed list of items

theArray = [[NSArray alloc] initWithObjects: @"One", @"Two", nil]; 

and use that in a picker’s titleForRow routine (standard wording, the only difference being the return statement):

return [theArray objectAtIndex: row];

the picker fills and works fine.

But, if I fill theArray using…

theArray = [[NSArray arrayWithArray: [textString componentsSeparatedByString: @"||"]];

the program bombs with a BAD ACCESS message. I have used NSLog to examine the textString, and a loop to verify that theArray contains the same data as if it were filled directly (including the “nil“) but can’t make the picker accept theArray for its row titles unless the array elements are hardwired in.

SOLUTION, add the word “retain“: I scrapped the arrayWithArrays and went with:

theArray = [[textString componentsSeparatedByString: @"||"] retain];

Apparently, the array you get with componentsSeparatedByString is autoreleased, and doesn’t stay around long enough for the picker to get populated. I’m new in the game, and not very knowledgeable about memory issues, so my explanation might not be 100%. But the program is now working.

  • 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-27T00:40:17+00:00Added an answer on May 27, 2026 at 12:40 am

    From Rob Smythe’s update to the question with the answer:

    SOLUTION, add the word retain: I scrapped the arrayWithArrays
    and went with:

    theArray = [textString componentsSeparatedByString @"||"]retain];
    

    Apparently, the array you get with componentsSeparatedByString is
    autoreleased, and doesn’t stay around long enough for the picker to
    get populated. I’m new in the game, and not very knowledgeable about
    memory issues, so my explanation might not be 100%. But the program is
    now working.

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

Sidebar

Related Questions

I edited this question after i found a solution... i need to understand why
I write a parser for some data structure, after hours of debugging I found
I use PHP 5.3.0 and after hours of searching found a php_memcache.dll that is
After several hours test, in iOS 4.0 and above I found if I draw
My question is similar to some I've found after googling for the last couple
After hours of debugging, I found an error in one of my scripts. For
After some hours creating a vb.net helper class for unit-tests and integrating moq into
I'm writing a physics simulating program, and found after() useful. I once would like
I've found that after changing the overlays on a MapView , the changes aren't
I need to blink between two colors:red and white. I've found that after $targetcss('background-color','red')

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.