我正在创建一个语言测验应用程序来学习 Obj-C,但我很难理解构建此类信息处理函数的正确方法。到目前为止:
我在一个单独的文本文件中收集了一组西类牙语单词及其定义。 以下是我在实现时遇到问题的代码的主要部分:
@implementation SGLDictionary
-(NSString*)makeStringFromFile:(NSString *)myFileName {
//read file and save to *string
return string;
-(NSArray *)getContentFromString:(NSMutableString *)string {
//Here the string is trimmed and deheadered so only the content is left and returned as an NSArray.
return Array;
-(NSMutableDictionary *)makeDictionaryFromArray:(NSArray *)array{
//make the array mutable and form it into a dictionary by looping over it
return spanishToEnglishDictionary;
您稍后如何初始化 SGLDictionary 类的实例并调用方法以便它们在实例上一一执行?我不确定这是如何工作的,因为我认为更改数据的方法不会返回任何内容(它们 return void
)。
最佳答案
- (NSMutableDictionary *)dictionaryFromFile:(NSString *)file
{
return [self makeDictionaryFromArray:[self getContentFromString:[self makeStringFromFile:file]]];
}
你的问题还不够吗?
你可以像这样调用这个方法
SGLDictionary *sgl = [[SGLDictionray alloc] init];
NSMutableDictionry *dic = [sgl dictionaryFromFile:file];
关于ios - 如何将应该在 Obj-C 中依次执行的方法构造在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24605005/