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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:13:52+00:00 2026-05-30T22:13:52+00:00

I declare an NSArray in one class like this: .h @interface HTTP : NSObject

  • 0

I declare an NSArray in one class like this:

.h

@interface HTTP : NSObject {
NSArray *listOfProfiles;
}
@property (nonatomic, retain) NSArray *listOfProfiles;

.m

-(id) init {
if ((self = [super init])) {
    listOfProfiles = [[NSArray alloc] init];
}
return self;
}

-(void) someMethod {
...
    case GET_LIST_OF_PROFILES:
        listOfProfiles = [result componentsSeparatedByString:@"^-^"];
        NSLog(@"first break: %@",[listOfProfiles objectAtIndex:0]);
        break;
...
}

I can access it here just fine, then when I try to access it in another class after creating an object I receive the error EXC_BAD_ACCESS and the debugger goes to main.m:

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
http = [[HTTP alloc] init];
[http createProfileArray];
profileListDelay = [[NSTimer alloc] init];
profileListDelay = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(profileListSelector) userInfo:nil repeats:YES];

}

- (void) profileListSelector 
{
if (http.activityDone)
{
    // http.listofprofiles mem leak?
    for (int i = 0; i < http.listOfProfiles.count; i++)
    {
        NSLog(@"%@",[http.listOfProfiles objectAtIndex:i]);
    }
    [profileListDelay invalidate];
    profileListDelay = nil;
}
}

I’m thinking it’s a memory issue maybe, but I could be completely 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-30T22:13:53+00:00Added an answer on May 30, 2026 at 10:13 pm

    It is a memory issue

    It is in someMethod

    -(void) someMethod {
    ...
        case GET_LIST_OF_PROFILES:
            listOfProfiles = [result componentsSeparatedByString:@"^-^"];
            NSLog(@"first break: %@",[listOfProfiles objectAtIndex:0]);
            break;
    ...
    }
    

    componentsSeparatedByString: returns an autoreleased object
    Since you declared the array as a retain property, you should update it like so:

    self.listOfProfiles = [result componentsSeparatedByString:@"^-^"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my objective c class, I'd like to sort an array like this: NSArray
I have a Singleton and I'd like to declare an NSArray, but I'd like
I need someones help to declare the following array:- self.tablePicture = [NSArray arrayWithObjects:@pic1.png, @pic2.png,
If I want to return an immutable array like this + (NSArray *)ids but
When I go look at NSArray's interface file, it doesn't declare any instance variable.
I declared NSArray in my class NSArray *labelsArray; I made it a property @property
I can declare NSMutableArray or NSArray but I want to declare class array. Let
declare @d varchar set @d = 'No filter' if (@d like 'No filter') BEGIN
I declare an NSArray in my code then building the array from another array.
I call a function with performSelectorInBackground, and in this function, I declare NSAutoreleasePool *pool

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.