小编Mic*_*ele的帖子

如何将参数传递给NSTimer中调用的方法

我有一个调用方法的计时器,但这个方法需要一个参数:

theTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(timer) userInfo:nil repeats:YES];
Run Code Online (Sandbox Code Playgroud)

应该

theTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(timer:game) userInfo:nil repeats:YES];
Run Code Online (Sandbox Code Playgroud)

现在这种语法似乎不对.我试过NSInvocation但我遇到了一些问题:

timerInvocation = [NSInvocation invocationWithMethodSignature:
        [self methodSignatureForSelector:@selector(timer:game)]];

theTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval
        invocation:timerInvocation
        repeats:YES];
Run Code Online (Sandbox Code Playgroud)

我该如何使用Invocation?

arguments objective-c nstimer nsinvocation

6
推荐指数
2
解决办法
1万
查看次数

要在目标c中浮动的字符串

我有一个解析器返回一些字符串值,我想用作我的类实例初始化的参数.

我有一个方法询问两个NSString和一个浮点值,但我不能将字符串转换为浮点数,这是我的代码:

 NSString *from = [[NSString alloc] initWithString:@"EUR"];
    NSString *to = [[NSString alloc] initWithString:[attributeDict objectForKey:@"currency"]];
    NSNumber *rate = [[NSNumber alloc] initWithFloat:[[attributeDict objectForKey:@"rate"] doubleValue]];


   currency = [[Currency init] alloc];
   [currency addCurrencyWithFrom:from andTo:to andRate:rate];
Run Code Online (Sandbox Code Playgroud)

在.h

- (id) addCurrencyWithFrom: (NSString *) from_ andTo:(NSString *) to_ andRate:(float *) float_;
Run Code Online (Sandbox Code Playgroud)

floating-point objective-c nsnumber nsstring

5
推荐指数
2
解决办法
2万
查看次数

从php中的静态函数访问私有变量

我班上有一个私有变量

private $noms = array(
        "HANNY",
        "SYS",
        "NALINE"
);
Run Code Online (Sandbox Code Playgroud)

我想从静态方法访问它:

public static function howManyNom($searchValue){

        $ar = $this->noms;

        foreach($ar as $key => $value) {

...
Run Code Online (Sandbox Code Playgroud)

但正常情况下,我无法使用$ this检索它,因为静态方法上没有实例.

在我的静态函数中获取$ noms的正确语法是什么?

php static

5
推荐指数
1
解决办法
1万
查看次数

3
推荐指数
1
解决办法
3334
查看次数

Eclipse问题代理连接:无法保存安全首选项

在此输入图像描述

嗨,如screeshot所示,eclipse在保存安全首选项文件时失败.已经尝试过777访问这些文件夹(事实上文件夹显示在安全 - >安全存储 - >内容,因为存储位置甚至不存在,所以我用mkdir创建它,我给它777访问权限.

但是,填写后,我点击应用而不是HTTP和HTTPS数据,用户和密码不会保存!

任何人?

eclipse proxy eclipse-plugin

3
推荐指数
1
解决办法
6044
查看次数

错误:分配中的类型不兼容

我构建了一个类并创建了一个初始化所有变量的方法.

在.h

-(void) initWithX:(float *)x_ andY:(float *)y_ andWidth:(float *)width_;
Run Code Online (Sandbox Code Playgroud)

并在.m

    -(void) initWithX:(float *)x_ andY:(float *)y_ andWidth:(float *)width_{
    [super init];
    x = x_;  ***
    y = y_;  ***
    width = width_; ***
}
Run Code Online (Sandbox Code Playgroud)

*的行给我错误"分配中的不兼容类型",但我不明白:我在.h中给出3个浮点数!

谢谢你们

floating-point objective-c init

1
推荐指数
1
解决办法
2862
查看次数