IOS/objective-C : Class Method in Interface Error

标签 ios objective-c class-method

我从一个没有导致错误的教程中复制了以下内容到我的项目中,它在指示的行上导致了三个错误。 (错误似乎不正确,因为当我尝试修复它们时,会出现其他错误。)任何人都可以提出可能的问题:

@interface VC ()
   NSDictionary(JSONCategories) //MULTIPLE ERRORS THIS LINE including cannot declare variables inside @interface
+(NSDictionary*)dictionaryWithContentsOfJSONURLString:(NSString*)urlAddress;
-(NSData*)toJSON;
@end

最佳答案

这是一个 NSDictionary 类别;你想要:

@interface NSDictionary(JSONCategories)
+(NSDictionary*)dictionaryWithContentsOfJSONURLString:(NSString*)urlAddress;
-(NSData*)toJSON;
@end

Apple Reference .

关于IOS/objective-C : Class Method in Interface Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33170906/

相关文章:

objective-c - 带有动画的ios简单条形图

ios - 将 Obj-C 观察器转换为 Swift 语法时遇到问题

Python:将静态方法分配给类变量会出错

Objective-C:什么是 [ClassName self];做?

ios - 在 UIDatePicker 上设置时间范围

ios - 设置 firebase_messaging 后,在 Iphone 上安装会卡住

php - 在 MySql 和 Objective C 之间传递数据

ios - 为 UITableViewCell 中的特定单元格设置颜色

python - 对类方法使用 pydispatch 和装饰器

ios - “禁止。需要用户。”保存QBCOCustomObject时出现错误