当我打电话给当地的例行程序时,我收到了这个警告.

我的代码是:

-(void)nextLetter {
    // NSLog(@"%s", __FUNCTION__);
    currentLetter ++;
    if(currentLetter > (letters.count - 1))
    {
        currentLetter = 0;
    }
    self.fetchLetter;
}

我自己也收到了警告.一封信的声明.

这个程序看起来是这样的:

- (void)fetchLetter {
    // NSLog(@"%s", __FUNCTION__);
    NSString *wantedLetter = [[letters objectAtIndex: currentLetter] objectForKey: @"langLetter"];

    NSString *wantedUpperCase = [[letters objectAtIndex: currentLetter] objectForKey: @"upperCase"];    


.....   
}

我更喜欢修正警告信息,有没有更好的方法来写这个?

谢谢

推荐答案

点符号(即self.fetchLetter)用于属性,而不是任意方法.self.fetchLetter被解释为"获取‘self’的‘fetchLetter’属性",这不是你想要的.

就用[self fetchLetter]吧.

Objective-c相关问答推荐

[NSNull new]和[NSNull NULL]有什么不同?

Apple Silicon 上的 dispatch_time 计算失败

NSNumberFormatter 和 'th' 'st' 'nd' 'rd' (序数)数字结尾

禁用手势识别器

如何删除警告按钮的框架在运行时会有所不同.

用 UIActivityIndi​​catorView 替换 UIBarButtonItem

NSTimeZone:localTimeZone 和 systemTimeZone 有什么区别?

NSLocale 和国家名称

如何将 NSDate 转换为今天、昨天、一周前、一个月前、一年前等相对格式?

NSMutableDictionary 线程安全

如何使用整数值作为键在 NSMutableDictionary 中设置值?

在 iOS 设备上本地存储图像

块引用作为Objective-C中的实例变量

MKMapView MKPointAnnotation 点击​​事件

iOS NSLayoutConstraint 使用 constraintWithItem 固定宽度

在字符串Objective-c中连接字符串

如何像在 Spotify 的播放器中一样创建居中的 UICollectionView

使用 UINavigationController 在 UIPageViewController 中下推内容

AVAudioPlayer 不播放任何声音

如何在没有死锁的情况下同步调度主队列?