且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Pinterest SDK将消息发送到已释放实例

更新时间:2023-02-15 16:41:17

我所做的是制作一个表示Pinterest类的静态变量:

What I did was make a static variable that represented the Pinterest class:

//I put this outside my @implementation code at the top of my m file
static Pinterest *_pinterest = nil;

// instantiating
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    _pinterest = [[Pinterest alloc] initWithClientId:clientId];
});

我认为Pinterest假定每个人都将其类用作静态单例,因为这可能是他们在内部执行的操作.公平地说,在大多数情况下,我不希望在单个应用程序中使用多个客户端ID.不过,我同意,这对他们来说是一个令人震惊的疏忽.他们甚至没有记录这种行为,他们在想什么?!

I think that Pinterest assumed that everyone would use their class as a static singleton because that's probably what they do internally. To be fair, I don't foresee using multiple client ID's with a single app in most cases. I agree, though, this is a stupefying oversight on their part. They didn't even document this behavior, what were they thinking?!