Trying to create USE_BLOCK_IN_FRAME ... EXC_BAD_ACCESS with NSFetchedResultsController

This is an update of my problem. I get this warning now when the program is interrupted. warning: attempt to create a variable USE_BLOCK_IN_FRAME with a block that is not in the frame.

I can not find much information about what this means.


It puzzled me. I get an EXC_BAD_ACCESS error. I have NSZombieEneabled (which helped with an earlier issue), but there is no call stack to track.

I have an almost identical code that works with another result controller I get.

This seems to be related to the relationship between the job object and the client object associated with it. This relationship is [object-object] <↔ [client object].

At first, I see that the code works without errors when the job object corresponding to the selected line does not have a client object linked through relations. Thus, in the event of a failure, this points to the client object, but when it does not fail, the pointer is zero.

When I encounter this problem, I launch the application and go directly to the task selection view and select the cell. At this point, a problem arises.

I did an experiment by running the application and first going into the client selection view, knowing that a selection of all client objects would be obtained. Then I went to view assignments and selected a cell. There was no problem.

Since I'm just trying to pass a pointer to a job object that has already been loaded, I don’t understand what is happening.

By the way, the code worked fine before switching to using NSFetchedResultsControllers. I like what they can do for me, but there is some kind of dynamics that I did not understand.

Logging does not show me anything that I understand to solve the problem.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { userState.selectedJob = [self.fetchedResultsController objectAtIndexPath:indexPath]; NSLog(@"\n\n(1 Pick) indexPath: %@\n",indexPath); NSLog(@"\n\n(1 Pick) userState: %@\n",userState); NSLog(@"\n\nnumber of Objects in job fetchresultscontroller = %d", [[fetchedResultsController fetchedObjects] count] ); NSLog(@"\n\n(1 Pick) selected job: %@\n",[self.fetchedResultsController objectAtIndexPath:indexPath]); // This line is causing the problem... NSLog(@"\n\n(1 Pick) selected job: %@\n",userState.selectedJob); // Omitting the line above, this line fails [self.navigationController pushViewController:userState.jobInfoTVC animated:YES]; } 

Debug output

 2011-05-07 09:27:04.142 job1[6069:207] (1 Pick) indexPath: <NSIndexPath 0x5952590> 2 indexes [0, 3] 2011-05-07 09:27:04.142 job1[6069:207] (1 Pick) userState: <UserStateObject: 0x5919970> 2011-05-07 09:27:04.143 job1[6069:207] number of Objects in job fetchresultscontroller = 4 (gdb) 

The final code should be so simple that it leads me to the whole journal:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { userState.selectedJob = [self.fetchedResultsController objectAtIndexPath:indexPath]; // Original failure was at this line [self.navigationController pushViewController:userState.jobInfoTVC animated:YES]; } 

I use singleton userState to track what the user has done. This way I save the last selected pointers to Job and selectedClient objects. This is normal until I switched to NSFetchedResultsController.

+7
source share
2 answers

I also had a problem with trying to create a variable USE_BLOCK_IN_FRAME with a block that is not in the frame . Although mine had nothing to do with NSFetchedResultsControllers.

Maybe your problem

I noticed that you mention that you are using singleton, so maybe your problem has been resolved by this link:

http://npenkov.com/2011/08/01/solving-issues-like-warning-attempting-to-create-use_block_in_frame-variable-with-block-that-isnt-in-the-frame/

From the link:

It was in the session manager that I used the macro, before @synthesize - this was a problem, static definitions should not appear in front of synthesized methods. Therefore, if you have something like:

 SYNTHESIZE_SINGLETON_FOR_CLASS(SessionManager) @synthesize loggedUserId, ... 

Just replace it with:

 @synthesize loggedUserId, ... SYNTHESIZE_SINGLETON_FOR_CLASS(SessionManager) enter code here 

My problem

The problem I ran into was duplicating a variable declaration, in this case a variable inherited from NSManagedObject:

 - (void)functionThatDoesSomething { VariableInheritedFromNSMObj *variableA = nil; for (VariableInheritedFromNSMObj *variableA in [self containerObject]) { NSLog(@"a = %@\n", [variableA name]); } [variableA setName:@"StackOverflow"]; } 

Moving the first line where variable A is initialized to zero after the loop fixes the problem. In my production code, I then changed the name of one of the variables.

Hope this helps you or someone else who is facing this issue. This error, apparently, manifests itself in different ways.

+1
source

Is the version of the target OS for deployment lower than you have debugging support in Xcode 4.2? When this happened to me, the deployment target somehow changed to 4.1, but I only had a 4.3 simulator with no additional support for debugging 4.0-4.1.

There are ways to fix this:

  • Set debugging symbols for your lower version of the OS from the Xcode settings. Go to the downloads, components and install OS 4.0 - 4.1 Support for debugging devices (or earlier, if you need it).
  • Set the deployment target to 4.3 or higher.

If you choose the first one, it is probably worth checking the checkbox in the settings for automatically downloading updates.

0
source

All Articles