Private Boolean: how to set on SKCropNode, with Swift?
Asked Answered
M

1

1

SKCropNode works by removing every thing from its affected nodes that are not covered by its source image. This is one type of masking, the other is to invert this logic, and reveal everything that's not covered by the source image.

SKCropNode has a boolean switch to set this state, called invertMask, sensibly enough.

What's annoying is that it's seemingly private.

If putting aside all the app store approval processes, dangers of private APIs, etc, and accepting that it's something interesting to test... and this is only for the purposes of testing...

How do I set this invertMask to true, with Swift?

UPDATE:

There are other answers to tangentially similar questions:

How to access iOS private APIs in Swift?

However that doesn't help me, nor is it a direct answer to how to do it for setting a boolean, this particular one, in this particular question, in Swift.

I've asked a question about Selectors here, and accepted an answer that showed me I didn't need to use or understand Selectors in order to achieve that goal: What is a selector in SKAction: perform(_:onTarget:)

But it looks like understanding the exact syntax required to use a Selector might be required to set this boolean in Swift. I don't know what that is, or how to do it, either.

But any other means of setting this boolean (in Swift) is certainly fine.

Merwyn answered 5/11, 2016 at 8:2 Comment(3)
I am not sure if the issue is that it is private, take a look here: github.com/JaviSoto/iOS10-Runtime-Headers/blob/master/… I am guessing it is not finished yet, and is not included in the released SDK.Greenwald
@Greenwald that's the link I provide in the question, on the word "private". These are private headers, private APIs. Whether or not they're finished can't be ascertained from the header, only by accessing it and trying to see if it works.Merwyn
I did not click on that link, those are not private headers, you are looking at a beta of the framework, if it was private, we wouldn't even see them in this context. If you take notice, some of the other items that are not private are available in this header as well, I would recommend downloading this program (RunTimeBrowser) and run it on the release frameworks and see if it still existsGreenwald
E
2

According to the latest Xcode 8.1 (build 8B62 with Apple Swift version 3.0.1) the official SKCropNode.h header is this below:

/**
 @header


 Node that can crop its children's contents with a mask


 @copyright 2011 Apple, Inc. All rights reserved.

 */

#import <SpriteKit/SKNode.h>
#import <SpriteKit/SpriteKitBase.h>

NS_ASSUME_NONNULL_BEGIN

/**
 A SpriteKit node that masks child nodes using another node's alpha component
 */
SK_EXPORT @interface SKCropNode : SKNode

/**
 SKNode to be used as the mask.

 The SKNode supplied as the mask must not be a child of another node, but it may have children. Anywhere the mask's output alpha component is less than 0.05 masks out that area for the SKCropNode's children. If the mask is nil, nothing is masked out.
 */
@property (nonatomic, retain, nullable) SKNode *maskNode;

@end

NS_ASSUME_NONNULL_END

As you can see there is no presence about invertMask, I'm sorry but I think this is no possible.

Eurythmic answered 5/11, 2016 at 11:9 Comment(13)
These are the official headers, the public ones. The ones I link to in the post (click on the word private, or in @KnightOfDragon's comment), you'll see behind the curtain.Merwyn
@Merwyn Your link report the old iOS 10 beta 8 headers. For this reason I want to specify the actual version in my answer. Take a look here github.com/JaviSoto/iOS10-Runtime-Headers/tree/master/…Eurythmic
are you saying that you're absolutely sure it's NOT available in the later versions of iOS 10?Merwyn
from two weeks after the release of the final version: github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/…Merwyn
I think you're failing to see behind the curtain. Apple doesn't just remove all the private parts they're working on when they release a full version. Everything you see in the iOS 10 beta 8 (and more) is in the full release. Whatever checking means you're using (that's created the code in your answer) isn't checking the private APIs, properties and methods. It's only showing the public, official stuff. I'm asking about how to use a private API.Merwyn
I'm cannot base my answer to you searching not official repositories and report it: to help you what I've do is to report the actual / current / official (source: Apple) SKCropeNode.h . You can do it making a new project and import SpriteKit.framework, then look the SKCropeNode.h file and you'll find my code in answer.Eurythmic
Here's an example of one that was around for YEARS before becoming generally available: #2103947 == this was used in several apps that were on the app store for the lifetime of it being hidden.Merwyn
Look at my question, I couched it carefully to say "I know... this is private stuff, etc... " It's not a crime to examine, test and explore the use of private APIs, most of them eventually become public...Merwyn
I agree with you, just for test you can do all. I think the problem is not "it's a crime", I preefer to say "it's a waste of time" if you want "tomorrow" to publish your stuff. For the rest I totally agree with you.Eurythmic
I updated the question with an example of how to access a private class, all greek to me.Merwyn
@Merwyn So you think I've not try to do (just make this answer without try) or don't know how to access to a private var?Eurythmic
I can't speak for what you know. I'm a great example of Dunning-Kruger with regards programming. I can't judge an expert from a professional from a guru. And I've no idea how far I am from any real understanding of modern programming.Merwyn
I've already couched everything in acknowledgement of the issues of using private APIs. So if your answer is "Don't do it, it's not professional", I get it... but that's not what I'm asking. I don't need advice on how to revere Apple's App Store policies, I'm perfectly capable of reading legalese until my eyes bleed. But this has nothing to do with anything that will be published, or even shared.Merwyn

© 2022 - 2024 — McMap. All rights reserved.