Apple开发_NSString 使用 strong 与 copy 进行修饰的区别

  • 测试代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    NSMutableString *m_notiion = [[NSMutableString alloc] init];
    m_notiion.string = @"房号密码的功能";
    self.m_notiion = m_notiion;
    [m_notiion appendString:@"加点文字"];

    CHLog(@"UIApplication == %@", self.m_notiion);
}
  • 使用 strong 修饰

    @interface GC_AppDelegate ()
    
    @property(nonatomic, strong) NSString *m_notiion;
    
    @end
    
    • 结果
  • 使用 copy 修饰

    @interface GC_AppDelegate ()
    
    @property(nonatomic, copy) NSString *m_notiion;
    
    @end
    
    • 结果
posted @ 2023-11-14 10:38  CH520  阅读(20)  评论(0编辑  收藏  举报