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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:24:45+00:00 2026-06-01T23:24:45+00:00

I am running a background thread to get data from a web service. To

  • 0

I am running a background thread to get data from a web service.

To get the settings needed for creating the URL I am using this method:

+(Settings *)getSettings
{
    Settings *settings = [[Settings alloc] init];
    NSString *path = [NSString stringWithFormat:@"Documents/Settings"];
    NSString *settingsPath = [NSHomeDirectory() stringByAppendingPathComponent:path];
    NSFileManager *fileMgr = [NSFileManager defaultManager];
    if ([fileMgr fileExistsAtPath:settingsPath]) {
        NSDictionary *settingsDictionary = [NSDictionary dictionaryWithContentsOfFile:settingsPath];
        settings.username = [settingsDictionary objectForKey:@"username"];
        settings.module = [settingsDictionary objectForKey:@"module"];
        settings.websiteUrl = [settingsDictionary objectForKey:@"websiteUrl"];

    }else
    {
        settings.username =  @"";
        settings.module =  @"";
        settings.websiteUrl =  @"";
    }
    NSLog(@"Settings = u:%@ m:%@ w:%@",settings.username,settings.module,settings.websiteUrl);
    return settings;
}

This works fine in the debugger but when i run it on the device i get BAD_EXCESS on the NSLog or on any class that tries to use the data with the warning:

warning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn’t in the frame.

This is the code works fine on the device if I step through the code.

Any ideas?

Edit:
Backtrace –

#0  0x37a97eda in objc_retain ()
#1  0x37aa4be4 in objc_retainAutoreleasedReturnValue ()
#2  0x0000f84a in +[SettingData getSettings] (self=0x175e4, _cmd=0x11af9) at /Users/Jono/Dropbox/Uni/iOS5/Feedback At Tees/Feedback At Tees/SettingData.m:49
#3  0x0000fa86 in -[DataManager init] (self=0x3509e0, _cmd=0x30fd9f96) at /Users/Jono/Dropbox/Uni/iOS5/Feedback At Tees/Feedback At Tees/DataManager.m:19
#4  0x00003b46 in __35-[MasterViewController viewDidLoad]_block_invoke_0 (.block_descriptor=0x185f40) at /Users/Jono/Dropbox/Uni/iOS5/Feedback At Tees/Feedback At Tees/MasterViewController.m:70
#5  0x30b08d54 in _dispatch_call_block_and_release ()
#6  0x30b0b896 in _dispatch_worker_thread2 ()
#7  0x37a0e1ce in _pthread_wqthread ()
#8  0x37a0e0a4 in start_wqthread ()

I tried adding the following to the init method of settings and if i step through it is ok if i dont it crashes on the second NSLog with the error: message sent to deallocated instance 0x160d60

-(id)init
{
    if ((self=[super init]))
    {
        NSString *path = [NSString stringWithFormat:@"Documents/Settings"];
        NSString *settingsPath = [NSHomeDirectory() stringByAppendingPathComponent:path];
        NSFileManager *fileMgr = [NSFileManager defaultManager];
        if ([fileMgr fileExistsAtPath:settingsPath]) 
        {
            NSDictionary *settingsDictionary = [NSDictionary dictionaryWithContentsOfFile:settingsPath];
            self.username = [settingsDictionary objectForKey:@"username"];
            self.module = [settingsDictionary objectForKey:@"module"];
            self.websiteUrl = [settingsDictionary objectForKey:@"websiteUrl"];
            NSLog(@"Settings = u:%@ m:%@ w:%@",self.username,self.module,self.websiteUrl);
        }
        else
        {
            self.username =  @"";
            self.module =  @"";
            self.websiteUrl =  @"";
        }
    }
    NSLog(@"Settings = u:%@ m:%@ w:%@",self.username,self.module,self.websiteUrl);
    return self;
}

Screenshot:
http://postimage.org/image/4vw6uq7pp/

  • 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-06-01T23:24:46+00:00Added an answer on June 1, 2026 at 11:24 pm

    First, the method should be retrieveSettings or downloadSettings or, just, settings, but not getSettings as get as a prefix has a very particular meaning regarding the argumentation of the method (pass by reference).

    Secondly, there is nothing obviously wrong with that code (save for the leak of settings, but that won’t cause this kind of a crash). (I see that ARC is enabled).

    Finally, if you have a crash then post the backtrace. The error message you are seeing (“USE_BLOCK_IN_FRAME”) indicates that the code you posted has nothing to do with the crash.


    Odd crash, that. OK — the warning is from the debugger and doesn’t have anything to do with the actual error.

    The scope boundary is often where the compiler will emit release and/or drain autorelease pools.

    Which leads to the next question; how are

    This is the code works fine on the device if I step through the code.

    OK — so, it doesn’t work when you run at full speed and does work when running step-by-step. Smells like a concurrency crash. Can you post a screenshot of the actual crash? I.e. are you sure that particular backtrace is the backtrace of the crash and not where the debugger happened to be at the time of the crash?

    (Yes, grasping at straws slightly — this crash doesn’t make sense with the evidence shown. I like puzzles.)


    OK — now we are getting somewhere. Sort of. It crashes outside the if’s scope after successfully logging the same thing inside the if’s scope.

    How are username, module and websiteURL defined? Are they strong or, most appropriately, copy @property declarations?

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

Sidebar

Related Questions

I have a TableModel that is populated from a background running thread. I am
I wanted a quick and easy way to get data from a URL without
Possible Duplicate: I need a good way to get data from a thread to
I'm aware, and use, the xxx.Dispatcher.Invoke() method to get the background thread to manipulate
I have a background thread running that fires events, but how can I ensure
Here is the situation: You have one long-running calculation running in a background thread.
I'm trying to execute a long-running piece of code in a background thread and
I'm running some background threads in the GUI. Currently I'm implementing a personal Thread
I have a thread running in the background. How do i send it messages
I'm having a big problem when calling a web service from my WPF application.

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.