Property anchorPoint cannot be found in forwar class object CALayer - objective-c

I downloaded this sample: https://developer.apple.com/library/ios/#samplecode/Touches/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007435
If I start the sample app everything is working fine.
I made my own app and copied most of the code into it. There is a method called adjustAnchorPointForGestureRecognizer: But in this method there is a error but only in my app (see screenshot): "Property anchorPoint cannot be found in forwar class object CALayer". I am wondering how I can solve this issue, I don't know what I did wrong. It is exactly the same code from the sample. Anyone can help? Thanks!

Did you import the QuartzCore framework into your project? Maybe that's why it can find the CALayer class
This error is thrown by XCode when it can't find a definition for CALayer. You should add the framework to your project and add #import <QuartzCore/QuartzCore.h> to wherever you are using the class

Related

Accessing WidgetCenter from Objective-C App

I have an existing Objective-C app and have developed a SwiftUI iOS 14 Widget for it. So far so good. Now I am trying to reload the timeline from my Objective-C app. I understand that there are no Objective-C api for accessing WidgetCenter, so I have implemented the bridging steps outlined in Apple's documentation (at least I think I have since I am totally new to Swift). I cannot seem to be able to get Widget Center nor WidgetCenter.shared.reloadAllTimelines()recognized in my Objective-C app. I have tried many approaches with no success, so I must be doing something wrong. Any help or suggestions would be greatly appreciated.
I faced with the same issue. The solution for this was to create a swift file for example: WidgetKitHelper. Create the assigned swift-objc header with that too (bridging header file) if it not generated automatically you can add it by manually (search for it).
In the helper object you can get access to widgetkit, and if you do the rest to be able to see the swift code from your objc code, you can use this as a wrapper.
Tips:
import WidgetKit
#available(iOS 14.0, *)
#objcMembers final class WidgetKitHelper: NSObject {
class func reloadAllWidgets(){
#if arch(arm64) || arch(i386) || arch(x86_64)
WidgetCenter.shared.reloadAllTimelines()
#endif
}
}
obj-c code:
First import the swift code by adding:
#import "YourProjectName-Swift.h"
Then you can use:
[WidgetKitHelper reloadAllWidgets];

Thread 1: signal SIGABRT when switching from Obj-c to Swift file

I have changed from Obj-c to swift. However in my view controller identity inspector, only Obj-c files are available when I try to set the custom class.
Any ideas how to get the Swift files to appear?
My issue was that my class was a subclass of UIViewController despite it being a UITableView. Changing this in the class worked.

Calling Google Plus Sign In inside of NSObject class rather than ViewController in IOS

I am trying to define methods for user login in my IOS app with Google+. I would like to do this in separate utility class rather than view controller (because I will expose these components to native react.js later).
My class header will look like following:
#interface LoginUtility : NSObject<GPPSignInDelegate>
+ (void)googleLogin
However, "GPPSignInDelegate" does not work inside NSObject class. After I implement like that, I start getting linker error like:
"_OBJC_CLASS_$_CMMotionManager", referenced from: objc-class-ref in GooglePlus(GPPSpamSignal.o)".
Note: I added all dependency libraries.
When I put the same code in ViewController, it just works fine. I also tried same logic with Facebook login and it worked perfectly.
Why is Google enforcing sign in method to be called inside ViewController?
Are there any ways to solve this problem?
Thanks in advance!
CMMotionManager is part of the CoreMotion framework. You obviously haven't linked that in correctly.

Linking to Quartz framework or ARC error?

I have the following code to generate a "noise texture" for an NSView background.
I have already linked the target to Cocoa and QuartzCore frameworks in the build phases, but the compiler keeps complaining with the following errors:
ARC semantic issue
"Receiver 'CIFilter' for class message is a forward declaration"
"Not known class method for selector filterWithName"
CIFilter *randomGenerator = [CIFilter filterWithName:#"CIColorMonochrome"];
[randomGenerator setValue:[[CIFilter filterWithName:#"CIRandomGenerator"] valueForKey:#"outputImage"]
forKey:#"inputImage"];
[randomGenerator setDefaults];
noisePattern = [randomGenerator valueForKey:#"outputImage"];
What's wrong here?.
I have already try all tricks that I can imagine off, to get rid of the errors. I know for sure this code works because it is a copy off an example project that compiles without any problems.
Any help is appreciated.
However you linked your project with QuartzCore framework you still need toimport appropriate header in your implementation file:
#import <QuartzCore/QuartzCore.h>

Compiler Error in a Blank Project

I've started a new Navigation-based project in X-Code. I delete the default grid view, add a new blank view, and connect it to the File's Owner via ctrl+click+drag, and it builds fine, but before anything happens on the iPhone simulator or the real thing, I get "Thread 1: Program recieved signal: "SIGABRT"" when the program hits "[self.window makeKeyAndVisible]". I'm really new to Objective-C and X-Code, but I know quite a bit of C# and C++. I don't really understand if I've set something in the IDE wrong, or what...any help would be greatly appreciated. Thanks!
When you create a new navigation project, the RootViewController class is a subclass of UITableViewController. Your error is due to removing the UITableView from the xib file, and replacing it with a UIView.
To fix this, you should change the super class of RootViewController to UIViewController. (Don't forget to remove the UITableView datasource and delegate methods from the implementation file for clarity.)