objective-c

iOS Screen recording detection

旧时模样 提交于 2021-02-08 10:22:15
问题 I tried to detect if screen capture is on for the application for iOS 11, to detect this the UIScreen.mainScreen.isCaptured property is used to check if it is recorded. It works fine for the first launch, when the app is terminated and launched again, then the API returns NO though the screen capture is on. Code: //In viewWillAppear block __block ViewController *weakSelf = self; [NSTimer scheduledTimerWithTimeInterval:2.0 repeats:YES block:^(NSTimer * _Nonnull timer) { [weakSelf

use delegate method written in objective-c in swift

限于喜欢 提交于 2021-02-08 10:19:14
问题 I'd like to use a delegate method written in Objecive-C in Swift. The method is included in the MGSwipeTableCell framework (MGSwipeTableCell.h). Objective-C: -(BOOL) swipeTableCell:(MGSwipeTableCell*) cell tappedButtonAtIndex:(NSInteger) index direction:(MGSwipeDirection)direction fromExpansion:(BOOL) fromExpansion; I try to convert it into swift to and use the method: func swipeTableCell(cell:MGSwipeTableCell, index:Int, direction:MGSwipeDirection, fromExpansion:Bool) -> Bool { return true }

OS X Status Bar Application with a title in two lines

我只是一个虾纸丫 提交于 2021-02-08 09:39:33
问题 I'm an old iOS developer and now I want to make a simple OS X status bar application. I need to put a title at the NSStatusItem but it should be in two lines, like iStatPro network feature. How should I add it? 回答1: Here is a very simple example. This example shows two lines with two simple blinking lights. It uses a NSView (Custom view) with two NSTextFields and two NSImageWells inside of it. The red and green light images are added to the project and set to the Image wells in IB. .m // //

Save received remote push notifications - ios

ぐ巨炮叔叔 提交于 2021-02-08 08:54:31
问题 Can we save the received push notifications locally in a plist? I have a reqiurment to show the number of unread push notifications in a badge view just like applicationIconBadgeNumber . But it should be shown inside the application, not as the icon badge view. So, my question is can we save the received push notifications in all the status of the application(running, background and quit)? I have implemented the push notifications, I can share the code if its necessary 回答1: If You have added

Mac OS In App Sandbox Entitlements Directory Read Issue

余生颓废 提交于 2021-02-08 08:54:23
问题 I am having an issue with my App Sandbox entitlements. My Mac OS app allows a user to open an XML file. When that file is parsed it reads a image file in the same directory as XML file. If App Sandbox is False, the image loads just fine. If App Sandbox is True, the image fails to load. (The XML file is still read) The App Sandbox must be True to push to the App Store. I have tried com.apple.security.files.user-selected.read-write = TRUE com.apple.security.temporary-exception.files.home

How to fix CFRuntimeCreateInstance object leak?

可紊 提交于 2021-02-08 08:51:10
问题 I'm having unseen object leak (CFRuntimeCreateInstance) when profiling my app with instrument leak tool. I have rough imagination where the leak occurs but unable to spot it :) The call tree points me to my class method for loading an image from a spritesheet. Here is a fragment of the call tree (until leaking object CFRuntimeCreateInstance): +[ImageCache loadImageOfType:andIndex:] +[NSString stringWithFormat:] _CFStringCreateWithFormatAndArgumentsAux CFStringCreateCopy _

get font-weight of an uitextview

北城以北 提交于 2021-02-08 08:35:17
问题 I want to resize the font-size in some UITextViews. That works fine with an outlet collection and this code: for (UITextView *view in self.viewsToResize) { if ([view respondsToSelector:@selector(setFont:)]) { [view setFont:[UIFont systemFontOfSize:view.font.pointSize + 5]]; } } But my problem is, that not every textView uses the systemFont in normal weight, some of them are in bold weight. Is it possible to get the font-weight? With a po view.font in the debug area I can see everything I need

How to prevent circular reference when Swift bridging header imports a file that imports Hopscotch-Swift.h itself

自古美人都是妖i 提交于 2021-02-08 07:46:36
问题 I am integrating Swift into a large existing Objective C project and have run into what I think is a circular reference. The classes in question are as follows: Objective C Controller #import "Hopscotch-Swift.h" @interface MyController : UIViewController<MyProtocol> ... @end Swift Protocol @objc protocol MyProtocol: NSObjectProtocol { ... } Bridging Header #import "MyController.h" This code fails to compile because the Hopscotch-Swift.h file will not generate. I think this is due to a

Date formatter for a certain format of date

你离开我真会死。 提交于 2021-02-08 07:33:51
问题 I might missing something, but I can't compose proper date formatter string for the date: 2016-01-14T10:24:26+0000 What is 'T' here? and how to include timezone? My string does not work: @"yyyy-MM-dd'T'hh:mm:ss Z" 回答1: You have to use 'T' in single quotes like below format to retrive string ftom date: yyyy-MM-dd'T'hh:mm:ssZ Let me know. 回答2: NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.dateFormat = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"; NSDate *yourDate =

ARKit – Spatial Audio barely changes the volume over distance

大城市里の小女人 提交于 2021-02-08 07:17:38
问题 I created a SCNNode and added an Audio to it. It is a Mono audio. Everything is set up correctly. It is working as Spatial Audio, that's not the problem. The problem is that as i get closer or far away it barely changes the volume. I know it changes if i get very very far away, but it's nothing like Apple demonstrated here: https://youtu.be/d9kb1LfNNU4?t=23 Some other games i see the audio volume really changing from one step distance. With mine, with one step you can't even tell the volume