Ios 由于uint8_t条件-目标C,未使用调用方法

Ios 由于uint8_t条件-目标C,未使用调用方法,ios,objective-c,for-loop,conditional-statements,uint8t,Ios,Objective C,For Loop,Conditional Statements,Uint8t,嘿,伙计们,我有这两种方法;而且我似乎不明白为什么我的digitalSMSCheck没有被调用 我的方法setInput从不断变化的外部源检索uint8\u t对象,因此它永远不是静态值。然后setInput方法调用另一个方法digitalInputAlertSystem,它传入旧的uint8\u t对象并生成一个新的uint8\u t对象来比较两者 然后我想用一个for循环遍历uint8\u t对象的8位,如果两个uint8\u t对象不相同,该循环将检查每个位,看看它是否被分配了与setIn

嘿,伙计们,我有这两种方法;而且我似乎不明白为什么我的
digitalSMSCheck
没有被调用

我的方法
setInput
从不断变化的外部源检索
uint8\u t
对象,因此它永远不是静态值。然后setInput方法调用另一个方法
digitalInputAlertSystem
,它传入旧的
uint8\u t
对象并生成一个新的
uint8\u t
对象来比较两者

然后我想用一个for循环遍历
uint8\u t
对象的8位,如果两个
uint8\u t
对象不相同,该循环将检查每个位,看看它是否被分配了与
setInput
方法中原始
uint8\u t
对象相同的值;然后,它将按位查找它们的不同位置,并通过
digitalSMSCheck
方法发送SMS警报(这是无法正确调用的)

-(void)setInput:(NCDigitalInput*)输入
{
NSLog(@“调用setInput”);
uint8_t值=输入值;
self.inputLabel.text=[NSString stringWithFormat:@“0x%0.2X”,值];
用于(UI开关*开关阵列中的温度)
{
温度开=(值和1);
值>>=1;
}
[自数字输入系统:输入:值];
}
-(void)digitalInputAlertSystem:(NCDigitalInput*)输入:(uint8\u t)旧值{
NSLog(@“调用的数字输入系统”);
uint8_t值=输入值;
NSUserDefaults*默认值=[NSUserDefaults standardUserDefaults];
NSString*基串;
NSString*smsString;
对于(int i=0;i>=1;
oldValue>>=1;
//[默认设置setBool:(value&i)forKey:[NSString stringWithFormat:@“digitalInput%dValueBool”,i]];
}
}
以下是digitalSMSCheck方法:

- (void) digitalSMSCheck:(int) pinNum :(NSString *)pinChangedNotificationValue{

    //the time permitted between alerts. A pin, when sending an alert, will be unable to send another for 3 seconds.
    dispatch_queue_t myQueue = dispatch_queue_create(("com.my.cool.new.queue"), DISPATCH_QUEUE_CONCURRENT);
        double delayInSeconds = 10.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds*NSEC_PER_SEC));
    dispatch_after(popTime, myQueue, ^(void){
        NSLog(@"The method DigitalSMSCheck was called");
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        for (int i = 0; i<=7; i++) {
            if ((i == pinNum) && !([defaults boolForKey:[NSString stringWithFormat:@"digitalInput%dRecentlyAlerted",pinNum%8]])) {
                [defaults setBool:FALSE forKey:[NSString stringWithFormat:@"digitalInput%dRecentlyAlerted",pinNum%8]];
                NSLog(@"The boolean for checking was successfully resetted to false; 1");
            }
        }
        for (int i = 8; i<=15; i++) {
            if ((i == pinNum) && !([defaults boolForKey:[NSString stringWithFormat:@"digitalOutput%dRecentlyAlerted",pinNum%8]])) {
                [defaults setBool:FALSE forKey:[NSString stringWithFormat:@"digitalOutput%dRecentlyAlerted",pinNum%8]];


                NSLog(@"The boolean for checking was successfully resetted to false; 2");
            }
        }


        dispatch_async(dispatch_get_main_queue(),^{
            [appDelegate watchPins:pinChangedNotificationValue];
            [self updateInput];
            [self updateOutput];
            [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:FALSE];

            [self setColors];
            [self setOutputSwitches];
        });

    });
}
-(void)digitalSMSCheck:(int)pinNum:(NSString*)pinChangedNotificationValue{
//警报之间允许的时间。发送警报时,pin在3秒内将无法发送另一个警报。
dispatch\u queue\t myQueue=dispatch\u queue\u create(((“com.my.cool.new.queue”)、dispatch\u queue\u CONCURRENT;
双延迟频率=10.0;
dispatch_time_t popTime=dispatch_time(dispatch_time_NOW,(int64_t)(DelayUnseconds*NSEC_PER_SEC));
在(popTime,myQueue,^(void)之后调度{
NSLog(@“调用DigitalSMSCheck的方法”);
NSUserDefaults*默认值=[NSUserDefaults standardUserDefaults];

对于(int i=0;我是否尝试过使用调试器单步执行代码?是的,我尝试过;我甚至添加了一些NSLog,似乎“digitalInput%dRecentlyAlerted”的布尔标志就是调用该问题的原因;存在该标志的任何地方代码都无法到达。您希望该值何时为真?您唯一一次将其设置为真在其中一个条件为FALSE后,您将其设置为FALSE的代码。如果此值始终为FALSE,则您将无法访问代码的
DigitalsScheck:
部分。@JamesSnook我希望在已发送警报时为true;这样系统就不会从SMS服务向用户发送太多文本消息。它应该将布尔值设置为true,表示“最近发送了一条消息”,然后在异步_调度队列延迟后完成时修改该布尔值,以便应用程序在必要时可以随意发送另一个警报。因此,当您执行此操作时,
(i==pinNum)&&&([defaults boolforky:[NSString stringWithFormat:@“digitalOutput%dRecentlyAlerted”,pinNum%8]]
是否要检查recentlyAlerted是否为TRUE(非FALSE),以便将其更改为FALSE?即,如果您最近收到警报,并且时间段已过,您希望将其更改为表示您最近未收到警报(如果您最近没有收到警报,请将其更改为您最近没有收到警报?)
- (void) digitalSMSCheck:(int) pinNum :(NSString *)pinChangedNotificationValue{

    //the time permitted between alerts. A pin, when sending an alert, will be unable to send another for 3 seconds.
    dispatch_queue_t myQueue = dispatch_queue_create(("com.my.cool.new.queue"), DISPATCH_QUEUE_CONCURRENT);
        double delayInSeconds = 10.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds*NSEC_PER_SEC));
    dispatch_after(popTime, myQueue, ^(void){
        NSLog(@"The method DigitalSMSCheck was called");
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        for (int i = 0; i<=7; i++) {
            if ((i == pinNum) && !([defaults boolForKey:[NSString stringWithFormat:@"digitalInput%dRecentlyAlerted",pinNum%8]])) {
                [defaults setBool:FALSE forKey:[NSString stringWithFormat:@"digitalInput%dRecentlyAlerted",pinNum%8]];
                NSLog(@"The boolean for checking was successfully resetted to false; 1");
            }
        }
        for (int i = 8; i<=15; i++) {
            if ((i == pinNum) && !([defaults boolForKey:[NSString stringWithFormat:@"digitalOutput%dRecentlyAlerted",pinNum%8]])) {
                [defaults setBool:FALSE forKey:[NSString stringWithFormat:@"digitalOutput%dRecentlyAlerted",pinNum%8]];


                NSLog(@"The boolean for checking was successfully resetted to false; 2");
            }
        }


        dispatch_async(dispatch_get_main_queue(),^{
            [appDelegate watchPins:pinChangedNotificationValue];
            [self updateInput];
            [self updateOutput];
            [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:FALSE];

            [self setColors];
            [self setOutputSwitches];
        });

    });
}