objective-c

How to ignore my app's window on screenshot? (Swift 2.0)

时光总嘲笑我的痴心妄想 提交于 2021-02-17 04:49:18
问题 I wanted to get an image of the screen, ignoring my app's window. Found a code example in Objective-C and tried to convert it to Swift. Objective-C snipped: // Get onscreen windows CGWindowID windowIDToExcude = (CGWindowID)[myNSWindow windowNumber]; CFArrayRef onScreenWindows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); CFMutableArrayRef finalList = CFArrayCreateMutableCopy(NULL, 0, onScreenWindows); for (long i = CFArrayGetCount(finalList) - 1; i >= 0; i--) {

How to ignore my app's window on screenshot? (Swift 2.0)

蹲街弑〆低调 提交于 2021-02-17 04:48:22
问题 I wanted to get an image of the screen, ignoring my app's window. Found a code example in Objective-C and tried to convert it to Swift. Objective-C snipped: // Get onscreen windows CGWindowID windowIDToExcude = (CGWindowID)[myNSWindow windowNumber]; CFArrayRef onScreenWindows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); CFMutableArrayRef finalList = CFArrayCreateMutableCopy(NULL, 0, onScreenWindows); for (long i = CFArrayGetCount(finalList) - 1; i >= 0; i--) {

LibXML doesn't find any nodes for my xpath expression

你离开我真会死。 提交于 2021-02-17 04:41:51
问题 I'm using xpath and LibXML in an iPhone app to find some nodes in an xml document. I'm a noob in xpath so probably i am doing something wrong. Here is the xml: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetUserByEmailResponse xmlns="http://tempuri.org/"> <GetUserByEmailResult> <id>4006</id> <name>Kudor Gyozo</name>

LibXML doesn't find any nodes for my xpath expression

寵の児 提交于 2021-02-17 04:40:22
问题 I'm using xpath and LibXML in an iPhone app to find some nodes in an xml document. I'm a noob in xpath so probably i am doing something wrong. Here is the xml: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetUserByEmailResponse xmlns="http://tempuri.org/"> <GetUserByEmailResult> <id>4006</id> <name>Kudor Gyozo</name>

Why is this program produces different result with `YES` and `true`?

拈花ヽ惹草 提交于 2021-02-17 02:06:16
问题 Here is the full program. Can you figure out its console output? #import <Foundation/Foundation.h> #define kEnv YES #if kEnv #define x @"abc" #else #define x @"xyz" #endif #define kVersion true #if kVersion #define y @"abc" #else #define y @"xyz" #endif int main(int argc, const char * argv[]) { @autoreleasepool { NSLog(@"x: %@; y: %@", x, y); NSLog(@"%@", kEnv ? @"abc" : @"cba"); NSLog(@"%@", kVersion ? @"abc" : @"cba"); } return 0; } Before moving forward, you can copy & paste, run, and

Why is this program produces different result with `YES` and `true`?

回眸只為那壹抹淺笑 提交于 2021-02-17 02:06:14
问题 Here is the full program. Can you figure out its console output? #import <Foundation/Foundation.h> #define kEnv YES #if kEnv #define x @"abc" #else #define x @"xyz" #endif #define kVersion true #if kVersion #define y @"abc" #else #define y @"xyz" #endif int main(int argc, const char * argv[]) { @autoreleasepool { NSLog(@"x: %@; y: %@", x, y); NSLog(@"%@", kEnv ? @"abc" : @"cba"); NSLog(@"%@", kVersion ? @"abc" : @"cba"); } return 0; } Before moving forward, you can copy & paste, run, and

The provided registration token is not registered

谁说胖子不能爱 提交于 2021-02-16 20:39:19
问题 I'm trying to send push notification for iOS via Google cloud functions but it returns error that The provided registration token is not registered . But I've checked it by debugging my app and the FCM registration token is correct. After that I've tried to send push notification via Firebase console to single device by providing FCM token but it failed due to Unregistered registration token . How this happens because there is no issue with device FCM token? 回答1: I think it should be some

Outlets cannot be connected to repeating content in CollectionView Cells

痴心易碎 提交于 2021-02-16 15:09:45
问题 When I am trying to connect a UILabel in a UICollectionViewCell that has been declared as @property (nonatomic, weak) IBOutlet UILabel *Title; It shows that: Outlet cannot be connected to repeating content. I have done some search and find out that I need to use some kinds of connection of the outlet between UIView and the UICollectionView. But I do not understand what to do exactly. So how could I make such a connection so that UILabel in the UICollectionViewCell can be accessed? 回答1: You

Outlets cannot be connected to repeating content in CollectionView Cells

不问归期 提交于 2021-02-16 15:08:19
问题 When I am trying to connect a UILabel in a UICollectionViewCell that has been declared as @property (nonatomic, weak) IBOutlet UILabel *Title; It shows that: Outlet cannot be connected to repeating content. I have done some search and find out that I need to use some kinds of connection of the outlet between UIView and the UICollectionView. But I do not understand what to do exactly. So how could I make such a connection so that UILabel in the UICollectionViewCell can be accessed? 回答1: You

Interpreting C pre pre processor code

自古美人都是妖i 提交于 2021-02-16 14:54:26
问题 Given #define LOG_OBJECT(object) (NSLog(@"" #object @" %@ %@:%d”, [object description], [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__)); The statement LOG_OBJECT(self); will produce: 2014-07-18 17:43:30.041 FrogCamera[12484:2144843] self ViewController.m:20 I wish to understand how the preprocessor code works. How can I see the statement that the pre processor produced? Specifically: Why the whole #define statement is wrapped in ( ) ? Is #object a text replacement for