question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Objective-C Blocks

See original GitHub issue

Hi, I stumbled upon a dead-end working with MCNearbyServiceAdvertiserDelegate. One of its required delegate methods involves an NSStackBlock, which is not callable. Is there a work around?

@protocol('MCNearbyServiceAdvertiserDelegate')
    def advertiser_didReceiveInvitationFromPeer_withContext_invitationHandler_(self, 
            advertiser, peerId, context, invitationHandler):
        invitationHandler(ObjcBool(True), self.session)

that code results in: Exception TypeError: "'__NSStackBlock__' object is not callable" in 'pyobjus.pyobjus.protocol_forwardInvocation' ignored

<bountysource-plugin> --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/35269647-support-for-objective-c-blocks?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77137&utm_medium=issues&utm_source=github). </bountysource-plugin>

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
SoundsSeriouscommented, Jun 18, 2018

A quick follow up to this. I’ve found that while its most convenient from a code writing standpoint to just leverage pyobjus to use objc directly from python there are alot of time this breaks.

MY SUGGESTION: Make a .dylib file in objc. Import this using pyobjus then you can call from some custom functions from pythohn, and get the right data you need. This has saved me alot of time and always works, but its a bit more work.

Good Luck!

0reactions
mbrockman1commented, Aug 1, 2020

If anyone has some tips or sample code I could follow, I would greatly appreciate it. I am trying to do access HealthKit data like @SoundsSerious however I’m 2 years late to the party. I am working on making a dylib file now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with Blocks - Apple Developer
Describes elements of best practice when writing code with Objective-C using ARC.
Read more >
Blocks and Closures in Objective-C | by Amy Joscelyn - Medium
Blocks are hard. Conceptually difficult to understand, blocks are nonetheless integral to many facets of Objective-C and other languages.
Read more >
Objective-C Blocks - Tutorialspoint
Objective-C Blocks, An Objective-C class defines an object that combines data with related behavior. Sometimes, it makes sense just to represent a single ......
Read more >
Introduction to Objective-C Blocks - AppCoda
This programming tutorial gives you an introduction of Objective-C blocks that was introduced in iOS 4.0 SDK. Blocks is a feature similar to ......
Read more >
Objective-C Blocks - raywenderlich.com - YouTube
Blocks are a language-level feature added to C, Objective - C and C++, which allow you ... such as requesting information from a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found