objective-c

Is it possible that Bridging-header turns (void (^)(NSError *))block (ObjC) into block: () throws -> () (Swift)?

六月ゝ 毕业季﹏ 提交于 2021-02-10 18:21:08
问题 I have OBJC: - (void)doSomething:(void (^)(NSError *))block; SWIFT: let test = Test() test.doSomething(<#T##block: ((Error?) -> Void)!##((Error?) -> Void)!##(Error?) -> Void#>) I would rather try? test.doSomething { } I would like bridging-header to translate the function into func doSomething(block: () throws -> ()) throws { try block() } Is it possible? Thanks to all! 回答1: Your Objective-C method is declaring a parameter which is a block that receives an NSError object. It's basically

Cannot find protocol declaration for 'UNUserNotificationCenterDelegate' in -Swift.h file

廉价感情. 提交于 2021-02-10 18:06:57
问题 I tried to convert my objective C AppDelegate to Swift AppDelegate. So I deleted the main.m file and Converted all the AppDelegate code to swift. I tried to run the project, then this error occurs. Cannot find protocol declaration for 'UNUserNotificationCenterDelegate' In the -Swift.h file they generate, this is the delegate they showed - (void)userNotificationCenter:(UNUserNotificationCenter * _Nonnull)center willPresentNotification:(UNNotification * _Nonnull)notification

Cannot find protocol declaration for 'UNUserNotificationCenterDelegate' in -Swift.h file

旧城冷巷雨未停 提交于 2021-02-10 18:02:37
问题 I tried to convert my objective C AppDelegate to Swift AppDelegate. So I deleted the main.m file and Converted all the AppDelegate code to swift. I tried to run the project, then this error occurs. Cannot find protocol declaration for 'UNUserNotificationCenterDelegate' In the -Swift.h file they generate, this is the delegate they showed - (void)userNotificationCenter:(UNUserNotificationCenter * _Nonnull)center willPresentNotification:(UNNotification * _Nonnull)notification

Realm: Migrating from ObjC to Swift

点点圈 提交于 2021-02-10 12:54:18
问题 I have an app written in ObjC. I've chosen Realm as my DataBase. I would like to start migrating some parts of my app to Swift. When getting to Realm I get confused. There are two pods . From what I understood from the docs, RealmSwift is for pure Swift projects, right? But, is it possible to migrate model classes to Swift without the RealmSwift pod ? 回答1: As I understand it, Realm Swift isn't exclusive for pure Swift projects, but if you do use it in an iOS app, you can't make any calls to

PKPaymentAuthorizationViewController not nil but not showing

你。 提交于 2021-02-10 09:24:09
问题 I'm trying to display a PKPaymentAuthorizationViewController which is not nil but isn't showing. I worked before but it doesn't anymore. The entitlement and merchant id seems good. Here is my init code (without useless code) PKPaymentRequest *request = [PKPaymentRequest new]; request.merchantIdentifier = kApplePayMerchantId; request.merchantCapabilities = PKMerchantCapability3DS; request.supportedNetworks = self.class.supportedNetworks; request.countryCode = _countryCode; request.currencyCode

NSScrollView how to start from top left corner

痴心易碎 提交于 2021-02-10 08:43:07
问题 How to set scrollView document view to be pinned to top left corner? If scrollView is big enough/bigger than its content, everything is drawn from bottom to up and it not looks right. I have to override isFlipped of scrollView? I was searching internet and overriding isFlipped to return true is not everything. I don't want to make my documentView flipped because then I have to make changes in that class to make everything looks like I want. 回答1: I created simple NSView class as an container

CoreMediaIO, incorrectly updated properties kCMIODevicePropertyDeviceIsRunningSomewhere

南笙酒味 提交于 2021-02-10 07:38:11
问题 I need to receive an event when some process starts using the camera. I did this through CMIOObjectGetPropertyData. But it does not work correctly, the correct value is only the first time it is accessed. I also tried to use the CMIOObjectAddPropertyListenerBlock but he did not work it from me. Tell me please, what am I doing wrong? I will be very grateful. while (1) { UInt32 value = 0; UInt32 valuePropertySize = sizeof(flag); CMIOObjectPropertyAddress opa =

How can i draw a bottom curve of the uiview using uibezierpath?

南楼画角 提交于 2021-02-10 06:30:47
问题 I'm tried to draw a bottom curve on UIimageview using uibezierpath. I don't know how to do that? - (void)setMaskTo:(UIView*)view byRoundingCorners: (UIRectCorner)corners { UIBezierPath *rounded = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(200.0, 200.0)]; CAShapeLayer *shape = [[CAShapeLayer alloc] init]; [shape setPath:rounded.CGPath]; view.layer.mask = shape; } i already tried like this https://imgur.com/a/WKykdyU I expect the output

ios

人走茶凉 提交于 2021-02-10 06:23:28
#import <UIKit/UIKit.h> @interface ScrollUpDownView : UIView // 设置 要现实的文字 @property(nonatomic, strong)NSArray * array; // 开启定时器 - ( void )onOpenTimer; // 关闭定时器 - ( void )onOffTimer; @end #import " ScrollUpDownView.h " @interface ScrollUpDownView () @property(nonatomic, weak)UILabel * label1; @property(nonatomic, weak)UILabel * label2; @property(nonatomic, assign)NSInteger count; @property(nonatomic, strong)NSTimer * timer; @property(nonatomic, assign) CGFloat mainH; @property(nonatomic, assign) CGFloat mainW; @property(nonatomic, assign) CGFloat mainX; @property(nonatomic, assign) CGFloat

mouseUp not firing in Cocoa?

自古美人都是妖i 提交于 2021-02-10 05:52:24
问题 I'm trying to implement drag&drop functionality in my app and I ran into a problem of my mouseUp event not firing. It fires just fine if I simply click and release on my view, but if I do drag, my mouseDragged event fires and that's it. By trying different things I figured out that the problem is in my dragImage call, but I don't know how to solve it for now. Here is my code: -(void) mouseDragged:(NSEvent *)theEvent { isDragging = YES; if ([selectedCellRowIndex longValue] >= 0) { NSImage *im