gpt4 book ai didi

objective-c - 在 Objective-C 中分配一个 IBOutlet

转载 作者:太空狗 更新时间:2023-10-30 03:40:22 26 4
gpt4 key购买 nike

代码生成器 Accessorizer可以选择分配 IBOutlets 而不是保留它们。例如,比较这两条生成的行:

@property(nonatomic,retain)IBOutlet UIImageView *backgroundView;
@property(nonatomic,assign)IBOutlet UIImageView *backgroundView;

为什么我要分配 IBOutlets,同时保留所有其他属性?

最佳答案

用法取决于 memory management guide 中指定的平台:

"The behavior of outlets depends on the platform (see “Mac OS X Desktop” and “iPhone”), so the actual declaration differs:

  For Mac OS X, you should use:

@property (assign) IBOutlet UserInterfaceElementClass *anOutlet;

For iPhone OS, you should use:

@property (nonatomic, retain) IBOutlet UIUserInterfaceElementClass *anOutlet;"

关于objective-c - 在 Objective-C 中分配一个 IBOutlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2106793/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com