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

  • Home
  • SEARCH
  • 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 6166653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:22:27+00:00 2026-05-23T22:22:27+00:00

Im using a threading class (.h/.m below) where the subclass is UIViewcontroller works without

  • 0

Im using a threading class (.h/.m below) where the subclass is UIViewcontroller works without any issues.

@interface myFirstClass : UIViewController <MyOperationDelegate>{

However when I use it where the subclass is a NSobject to call a reachability class checking for internet connection, the App crashes when calling performSelectorOnMainThread? I dont understand why, there are no error when I build the App and when it crashes all i get is EXC_BAS_ACCESS. Is it not possible to do this when dealing with an NSObject? Any suggestion will be helpful for me.

@interface AppController : NSObject <MyOperationDelegate>{

myThreading.h

@protocol MyOperationDelegate
    @required
    -(void) updatedStatus:(NSArray*)items;
    -(void) failedStatusWithError:(NSError*)error;
@end

@interface MyOperation : NSObject {    
    NSObject<MyOperationDelegate> * delegate;
    NSOperationQueue *queue;
}

@property (retain) NSObject<MyOperationDelegate> *delegate;

-(void)load: (NSString *)stringUrlPath:(NSString *)functionAction;

@end

myThreading.m

@interface MyOperation (NSObject)
    -(void)dispatchLoadingOperation:(NSDictionary *)aParameters;        
@end


@implementation MyOperation

@synthesize delegate;

-(id)init   
{
    if ([super init]!=nil) {
        queue = [NSOperationQueue new];
        [queue setMaxConcurrentOperationCount:1];
    }
    return self;
}

-(void)load: (NSString *)stringUrlPath: (NSString *)functionAction {

    [self dispatchLoadingOperation:[NSDictionary dictionaryWithObjectsAndKeys:
                                        stringUrlPath, @"urlString", functionAction, @"action", nil]];
}

-(void)dealloc {
        [queue cancelAllOperations];
        self.delegate = nil;
        [super dealloc];
}

-(void)dispatchLoadingOperation:(NSDictionary *)aParameters {

    if([aParameters objectForKey:@"action"] == @"getStatus"){
        @synchronized(self) {
            NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
                                                                                        selector:@selector(fetchCheckStatus:)
                                                                                          object:aParameters];
            [queue addOperation:operation];
            [operation release];
        }
    }
}


-(void) fetchCheckStatus:(NSDictionary *)aParameters
{   

    NSData* data = [[NSMutableData alloc] initWithContentsOfURL:[NSURL URLWithString:[aParameters objectForKey:@"urlString"]] ];

    NSError *error;
    NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    if (responseString != nil) {

        NSMutableArray *rssItems;

        [self.delegate performSelectorOnMainThread:@selector(updatedStatus:) withObject:[NSArray arrayWithObjects:rssItems, nil] waitUntilDone:NO];


    } else {
            [queue cancelAllOperations];
            [self.delegate performSelectorOnMainThread:@selector(failedStatusWithError:) withObject:error waitUntilDone:NO];
    }

    [responseString autorelease];
    [data release];
}
@end 
  • 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-23T22:22:28+00:00Added an answer on May 23, 2026 at 10:22 pm

    The problem are these lines:

    NSMutableArray *rssItems;
    
    [self.delegate performSelectorOnMainThread:@selector(updatedStatus:) withObject:[NSArray arrayWithObjects:rssItems, nil] waitUntilDone:NO];
    

    You declare a variable rssItems but don’t set it. It will contain random garbage from the stack which will then be interpreted as a pointer. Maybe sometimes you’re lucky and the value is actually a pointer to a living object, but more likely dereferencing it causes your crash.

    You need to actually initialize the variable, e.g.:

    NSMutableArray *rssItems = nil;
    

    but I guess you really want:

    NSMutableArray *rssItems = [NSMutableArray array];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code using System.Threading; class Test { volatile int counter = 0; public
When using module threading and class Thread() , I can't catch SIGINT ( Ctrl
using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program {
Im using asynchronous threading in my application WITH httpClient. I make a call using
Consider this code... using System.Threading; //... Timer someWork = new Timer( delegate(object state) {
I am developing a multi-threading application, which is deadlocking. I am using Visual C++
Using PyObjC , you can use Python to write Cocoa applications for OS X.
I'm experimenting Java Multi-Threading using synchronization on method comparing with Atomic variables (java.util.concurrent.atomic package).
I've made a class (code below) that handles the creation of a matching quiz
*Edit: Please see my answer below for the solution. Is there any danger in

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.