0

很快,这很简单。例如,如果我想添加一个自定义 Pinterest UIActivityType:

extension UIActivityType {
    static let postToPinterest = UIActivityType(rawValue: "pinterest.ShareExtension")
}

这就是我所要做的。但是,我对如何在objective-c中做到这一点有点困惑。我在想这样的事情,但我不太确定。

static UIActivityType UIActivityTypePostToPinterest = @"myApp.pinterest.ShareExtension";

任何帮助,将不胜感激。

4

1 回答 1

1

在 Objective C 中,UIActivityType只是 的另一个名称NSString,因此您可以将其声明如下:

// in header file
FOUNDATION_EXPORT static NSString * const UIActivityTypePostToPinterest;

// in implementation file
FOUNDATION_EXPORT static NSString * const UIActivityTypePostToPinterest = @"myApp.pinterest.ShareExtension";

虽然,由于 Objective C 没有命名空间,您应该使用自己的前缀(例如JNCActivityTypePostToPinterest代替UIApple 保留的 )。

于 2017-03-05T17:18:13.667 回答