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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:32:01+00:00 2026-05-26T02:32:01+00:00

I am basically having an issue with variable scope. Knowing multiple programming languages, I

  • 0

I am basically having an issue with variable scope. Knowing multiple programming languages, I just can’t wrap my head around obj-c sometimes.

In my webviewcontroller class I have a variable that I call using self.var

I also have some delegate methods that reference a modified UIAlertView. Why can’t I reference this self.var in those methods without the entire app crashing?

I have tried everything and its been a few days and now I need help!

Thanks!

Edit:

Here is the code webviewcontroller.h

    #import "SBTableAlert.h"

    @interface WebViewController : UIViewController <SBTableAlertDelegate, SBTableAlertDataSource>{
            NSMutableArray *bookmarks;
    }
    @property (nonatomic, retain) NSMutableArray *bookmarks;

here is the .m (yes I have an @synthesize for bookmarks), this is in view did load

    NSMutableArray *tmpArray = [tmpDict objectForKey:@"myKey"];
    self.bookmarks = tmpArray;
    [tmpDict release];
    [tmpArray release];

    SBTableAlert *bookmarkAlert;

    bookmarkAlert = [[SBTableAlert alloc] initWithTitle:@"Jump to:" cancelButtonTitle:@"Back" messageFormat:nil];
    [bookmarkAlert.view setTag:1];
    [bookmarkAlert setDelegate:self];
    [bookmarkAlert setDataSource:self];

NSString *settingsicon = [[NSBundle mainBundle] pathForResource:@"gear" ofType:@"png"];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageWithContentsOfFile:settingsicon] style:UIBarButtonItemStylePlain target:bookmarkAlert action:@selector(show)];

and later I try to call self.bookmarks

    - (NSInteger)tableAlert:(SBTableAlert *)tableAlert numberOfRowsInSection:(NSInteger)section {
            return [self.bookmarks count];
    }

The error I get at the self.bookmarks count is NSInvalidArgumentException

  • 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-26T02:32:01+00:00Added an answer on May 26, 2026 at 2:32 am

    It’s a bit hard to answer without seeing some of your code.

    Like Farmer_Joe asked, how are you defining the property? Something like:

    @property (nonatomic, retain) MyVar *var;
    

    is different from

    @property MyVar *var;
    

    How are you assigning to the var?

    var = value;
    

    won’t kick in the retain, but this would (if the property is defined as “retain”):

    self.var = value
    

    Edit: based on the new code you posted, it looks like you’re over-releasing tmpArray. Remove this line:

    [tmpArray release];
    

    You shouldn’t have to release tmpArray, because this line doesn’t retain it:

    NSMutableArray *tmpArray = [tmpDict objectForKey:@"myKey"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with rails involving javascript. Basically, I have the following code:
Basically my task is having to sort a bunch of strings of variable length
I'm having an issue with PHP losing data in a variable. There is quite
I'm having a weird issue that I can't track down... For context, I have
I am having an issue with many-to-many mapping using NHibernate. Basically I have 2
Hey Guys, having an issue with Linq-to-SQL, I am basically doing the following but
I'm having an IE7 issue with a website i'm working on - www.mini-meals.co.uk Basically,
Basically I'm having a little issue here. I have a superclass and a subclass.
I'm having an issue with the syntax for modules. Basically I'm trying to split
I am having a issue with boost unit testing. Basically I create a fixture

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.