Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ios中链接静态库_Ios_Xcode4_Static Linking - Fatal编程技术网

在ios中链接静态库

在ios中链接静态库,ios,xcode4,static-linking,Ios,Xcode4,Static Linking,我在Xcode 4.4中创建了一个基于数学的应用程序。我在故事板的帮助下使用基于tabbar的应用程序 我在一个名为CalculationMethods的单独类中编写了所有数学函数,该类是NSObject的子类 我的ViewController: // FirstViewController.h #import <UIKit/UIKit.h> #import "CalculationMethods.h" @interface FirstViewController : UIVi

我在Xcode 4.4中创建了一个基于数学的应用程序。我在故事板的帮助下使用基于tabbar的应用程序

我在一个名为
CalculationMethods
的单独类中编写了所有数学函数,该类是NSObject的子类

我的ViewController:

//  FirstViewController.h

#import <UIKit/UIKit.h>
#import "CalculationMethods.h"

@interface FirstViewController : UIViewController

@end

//  FirstViewController.m

#import "FirstViewController.h"
#import "CalculationMethods.h"

@interface FirstViewController ()

@end

@implementation FirstViewController



- (void)viewDidLoad
{
    [super viewDidLoad];

    NSLog(@"%f",[self julianDateFinder: [self currentDayMonthAndYearFinder]]);
}

@end
//FirstViewController.h
#进口
#导入“CalculationMethods.h”
@界面FirstViewController:UIViewController
@结束
//FirstViewController.m
#导入“FirstViewController.h”
#导入“CalculationMethods.h”
@接口FirstViewController()
@结束
@FirstViewController的实现
-(无效)viewDidLoad
{
[超级视图下载];
NSLog(@“%f”,[self-julianDateFinder:[self-currentDayMonthAndYearFinder]];
}
@结束
如您所见,我已将CalculationMethod.h文件包括在FirstViewController.h和FirstViewController.m文件中,但当我使用该类的方法,如
julianDateFinder
currentDayMonthAndYearFinder
时,Xcode错误如下:

“没有可见的@interface for'FirstViewController'声明选择器'CurrentDayMonthAndYearFinder'”


我不熟悉iOS和XCode。有人能帮我解决这个错误吗

我想你有点误解了Objective C的工作原理

如果不添加
CalculationMethods.h
头文件的详细信息,我帮不了你多少忙,但是编译器的警告告诉你
FirstViewController
没有方法
currentDayMonthAndYearFinder

出现这种情况的原因是,您正在调用对
self
执行选择器
CurrentDayMonthAndYearFinder
,在
FirstViewController
实例的上下文中,它实际上是
FirstViewController

您自己说过您的方法
CurrentDayMonthAndYearFinder
在您的
CalculatorMethods
类上,因此我建议您创建CalculatorMethods类的实例,或者在CalculatorMethods类上调用名为
CurrentDayMonthAndYearFinder
的类方法

这里的问题在于你是否定义了实例方法或类方法


帮自己一个忙,用FirstViewController中的
CalculationMethods.h

的内容更新您的问题。要使用CalculationMethods类中的任何方法,您需要创建CalculationMethods的实例。然后使用以下语法访问一个方法:
[instanceOfCalculationMethods aMethodInCalculationMethods]

例如,在您的案例中,请尝试以下方法:

在FirstViewController.h文件中,在@end之前:

CalculationMethods *_calculationMethods;
在viewDidLoad方法中:

_calculationMethods = [CalculationMethods alloc] init];
NSLog(@"%f",[_calculationMethods julianDateFinder: [_calculationMethods currentDayMonthAndYearFinder]]);

你的CalculationMethods.h文件是什么样子的?我也不认为你指的是客观C意义上的静态库。我在那里实现了它谢谢!!!为了您的帮助,我实际上是C开发人员,对iOS开发完全陌生,这是我开发的第一个应用程序,所以我忘了我已经创建了一个新类&为了首先使用一个类,我必须创建它的实例。您还可以编写纯C风格的函数,并在.h文件中声明它们,并在.m文件中实现它们。因此,您可以使用这些函数,而无需指向Obj-C类实例的指针。但这将是另一个如此重要的问题……:)