如何正确地将此函数从 Obj-c 转换为 Swift __attribute__((nonnull(1)));

问题描述 投票:0回答:0

下午好,我是一名新手开发人员,我的任务是将库从 Obj-c 翻译成 Swift

- (id<ACReusableObject>)dequeueReusableObjectWithIdentifier:(NSString *)identifier __attribute__((nonnull(1)));

整个文件看起来像这样

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "ACReusableObject.h"


extern NSString * const ACReuseQueueEmptyException;


@interface ACReuseQueue : NSObject

+ (instancetype)defaultQueue;

@property (nonatomic, assign) NSUInteger maxUnusedCount;

- (void)enqueueReusableObject:(id<ACReusableObject>)reusableObject;

- (id<ACReusableObject>)dequeueReusableObjectWithIdentifier:(NSString *)identifier __attribute__((nonnull(1)));

- (void)registerNib:(UINib *)nib forObjectReuseIdentifier:(NSString *)identifier __attribute((nonnull(1,2)));

- (void)registerNibWithName:(NSString *)nibName bundle:(NSBundle *)nibBundle forObjectReuseIdentifier:(NSString *)identifier __attribute((nonnull(1,3)));

- (void)registerClass:(Class)objectClass forObjectReuseIdentifier:(NSString *)identifier __attribute((nonnull(2)));


@property (nonatomic, assign, readonly) NSUInteger unusedCount;
@property (nonatomic, assign, readonly) NSUInteger usedCount;
@property (nonatomic, assign, readonly) NSUInteger count;

- (void)removeAllUnusedObjects;

@end

请告诉我如何正确编写这个函数。

另外,如果您有任何更好的方法,请写信给我!我会非常感谢你! 谢谢。

我为此使用了Objc2Swift.js,但我无法转换一个文件,它在这一行给出了语法错误

swift objective-c frameworks func
© www.soinside.com 2019 - 2024. All rights reserved.