omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Objc_tools Library

    Pythonista
    4
    5
    3958
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scj643
      scj643 last edited by scj643

      https://github.com/scj643/objc_tools
      My pride and joy

      I also have a slack chat for it reply if you are interested.

      purple_cyborg ryanryanryan 2 Replies Last reply Reply Quote 0
      • purple_cyborg
        purple_cyborg @scj643 last edited by

        @scj643 Awesomeness

        1 Reply Last reply Reply Quote 0
        • scj643
          scj643 last edited by

          I also need people to help with documentation and refactoring

          1 Reply Last reply Reply Quote 0
          • ryanryanryan
            ryanryanryan @scj643 last edited by

            @scj643 I know it must be disturbing, but may I ask if you can help me to transfer CMPedometer query into objc_ulti codes? I read a lot of your wonderful obj scripts, and they are amazing!

            I want to query the step data using objc_ulti, but I know nothing of ObjC :(

            Here's the code I searched on the internet which may be helpful.

            //initialize
                self.pedometer = [[CMPedometer alloc]init];
            
                //if step counting is available
                if ([CMPedometer isStepCountingAvailable]) {
                    [_pedometer queryPedometerDataFromDate:[NSDate dateWithTimeIntervalSinceNow:-60*60*24*2] toDate:[NSDate dateWithTimeIntervalSinceNow:-60*60*24*1] withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) {
                        if (error) {
                            NSLog(@"error====%@",error);
                        }else {
                            NSLog(@"Steps====%@",pedometerData.numberOfSteps);
                            NSLog(@"Distance====%@",pedometerData.distance);
                        }
                    }];
                }else{
                    NSLog(@"Unavailable");
                }```
            No matter what, thanks for your contributions.
            1 Reply Last reply Reply Quote 0
            • shaun-h
              shaun-h last edited by shaun-h

              I did a quick translation of the code to run with objc_utils

              from objc_util import ObjCClass, ObjCBlock, c_void_p, ns, ObjCInstance
              
              def getData(_cmd, pedometerData, error):
              	ped = ObjCInstance(pedometerData)
              	
              	if not error == None:
              		err = ObjCInstance(error)
              		print('error===='+str(err))
              	else:
              		print('Steps===='+str(ped.numberOfSteps()))
              		print('Distance===='+str(ped.distance()))
              		
              ped_block = ObjCBlock(getData, restype=None, argtypes=[c_void_p, c_void_p, c_void_p])
              CMPedometer = ObjCClass('CMPedometer')
              NSDate = ObjCClass('NSDate')
              
              ped = CMPedometer.alloc().init()
              
              if CMPedometer.isStepCountingAvailable():
              	fromDate = NSDate.dateWithTimeIntervalSinceNow_(-60*60*24*2)
              	toDate = NSDate.dateWithTimeIntervalSinceNow_(-60*60*24*1)
              	ped.queryPedometerDataFromDate_toDate_withHandler_(ns(fromDate),ns(toDate),ped_block)
              else:
              	print('Unavailable')
              

              I hope it helps.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors