Utilsファイルを作成して、いくつかの関数を作成し、それらをいくつかのクラスで使用したいのですが、その方法がわかりません。
私は持っています:
Utils.h
#import <Foundation/Foundation.h>
@protocol Utils
@optional
-(NSString*)colorToHex:(UIColor*)color;
@end
@interface Utils : NSObject
@end
Utils.m
#import "Utils.h"
@implementation Utils
-(NSString*)colorToHex:(UIColor*)color{
return @"Working";
}
@end
mainClass.h(スニペット)
@interface StyleTableViewController : UITableViewController <Utils>
mainClass.m(呼び出し)
NSString *myString = [self colorToHex:color];
NSLog(@"%@",myString);
また、関数を呼び出すとクラッシュします。私は何をすべきか?
ありがとう