ios - 如何将应该在 Obj-C 中依次执行的方法构造在一起

标签 ios iphone objective-c xcode

我正在创建一个语言测验应用程序来学习 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/

相关文章:

iphone - 界面生成器 "Simulate Interface"不工作

iphone - 在 UIWebView 中打开 PDF url 并从中复制,应用程序崩溃

iphone - UIOrientation 返回 0 或 5

iphone - 下载并保存可以为空白的图像

javascript - 在 WebkitView 中注入(inject) JavaScript 以监听文档正文以查找不适用于所有网页的任何点击事件

android - Sencha 架构师——部署

iphone jquery-mobile 下载图片

ios - 如何在 iOS 中创建带有阴影和 subview 的 UIimageView

objective-c - 如何将包含核心动画层的 View 渲染到位图?

iOS:如何更改 UISplitViewController 中分隔符的颜色?