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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:08:35+00:00 2026-05-31T18:08:35+00:00

I want to persist a block inside core data NSManagedObject if it’s possible. I

  • 0

I want to persist a block inside core data NSManagedObject if it’s possible. I have an inherited class from NSManagedObject.
This class have a block to satisfy some asynchronous calls. I tried to store the block as a Transformable and Transient attribute. when I try to invoke the block before load my NSManagedObject I have a bad memory access "EXC_BAD_ACCESS" .

If I don’t check the transformable flag I have an exception similar to this:

-[__NSStackBlock__ encodeWithCoder:]: unrecognized selector sent to instance 0xbfffd930

I’m new in iOS. I’m working under iOS 5 SDK with ARC enabled. This is a extract from my code:

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class ModbusRegister, Board;
typedef void (^DataBlockType)(NSArray *listRegister);

@interface EnergyEntry : NSManagedObject
- (void)invokeWithData: (NSArray *)listRegister;

@property (nonatomic, copy) DataBlockType  datablock;

@end

#import "EnergyEntry.h"

@implementation EnergyEntry

@dynamic datablock;

- (void)invokeWithData: (NSArray *)listRegister{

    self.datablock(listRegister);
}

@end

When I tried to store the block:

[energyEntry setValue:@"Energía activa" forKey:@"name"];
[energyEntry setValue:[NSNumber numberWithDouble:0] forKey:@"value"];
[energyEntry setValue:currentBoard forKey:@"board"];

[energyEntry setValue:^(NSArray *listRegister){
    //...my block operations to store
} forKey:@"datablock"];

Finally when I invoke the block and the error is fired:

NSArray *listRegister=... //my ready array
[energyEntry invokeWithData:listRegister];
  • 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-31T18:08:36+00:00Added an answer on May 31, 2026 at 6:08 pm

    You can’t store a block as a transformable type. According to Apple documentation transformable object has to be convertible to NSData. Block can’t be converted to NSData because it is a compiler’s reference to compiled code, not some data that can be moved around.

    Just a note, that the block is like an anonymous method. You can call it many times, each time with a different parameter. So nothing is stopping you from storing the block once and calling it many times in each asynchronous call separately. If you think that you need many blocks then most likely you just need to store the data that should be passed to each block invocation.

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

Sidebar

Related Questions

I have a class which I want to persist with OrmLite and it stores
I am using C++ and MySQL. I have data objects I want to persist
I want to persist 2 CLLocations between app launches. This is the ONLY data
I have a Map, that I want to persist. The domain object is something
I want to persist some data into a text file in my C# application.
I have a class called EditMapUtilities. Here are some class properties that I want
I have an ActiveAdmin app with a simple model that I want to persist
I want to persist some data between web requests using JavaScript. I would use
I have multiple publishers which want to persist their subscription info in storage. Is
I have an object with an array property that I want to persist 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.