English 中文(简体)
工作周期的中断?
原标题:Block life cycle in function?

客观的变量是一个参考,我从某些地方了解到,以下代码可由汇编者转换为另一种形式。

Original code:

typedef int (^block_type)();
block_type create_k(int i)
{
    block_type block = ^(){
        return i;
    };
    //[block copy];
    return block;
}

Generated Code:

typedef void (*generic_invoke_funcptr)(void *, ...);
struct __block_literal {
    void *isa;
    int flags;
    int reserved;
    generic_invoke_funcptr invoke;
    struct __block_descriptor_tmp *descriptor;
    const int captured_i;
};
static const struct __block_descriptor_tmp {
    unsigned long reserved;
    unsigned long literal_size;
    /* no copy/dispose helpers needed */
} __block_descriptor_tmp = {
    0UL, sizeof(struct __block_literal)
};
// ^int (void) { return i; }
int __create_k_block_invoke_(struct __block_literal *bp) {
    return bp->captured_i;
}
typedef int (*iv_funcptr)(struct __block_literal *);

typedef int (^block_type)();
block_type create_k(int i)
{

    //block_type block = ^(){
    //    return i;
    //};
    struct __block_literal __b = {
        .isa = &_NSConcreteStackBlock,
        .flags = BLOCK_HAS_DESCRIPTOR,
        .reserved = 0,
        .invoke = (generic_invoke_funcptr)__f_block_invoke_,
        .descriptor = &__block_descriptor_tmp,
        .captured_i = i
    };
    struct __block_literal *block = &__b;
    return block;
}

因此,<>>>>>在座标和栏目中仅提及<>>>>。 如果有的话,接收人只能拿一个无效地址。

But

 int main(int argc, const char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    printf("%d
", create_k(40)());
    [pool drain];
    return 0;
}

印刷版第40期和<24期>是有效部件。 问题是什么?

最佳回答

我的猜测是,这一 st框架的记忆尚未消失。 要求在制造_k()和印刷(f)之间增加另一个功能,以便在那里获得一些其他随机数据。

问题回答

暂无回答




相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签