Skip to content

Allow Serialisation of PMKArray #1362

Open

Description

@tmolitor-stud-tu

Are you interested in a PR for this small category addon to PMKArray making it serializable?
We are using this in Monal for about a year now and I can create a PR, if you want to add this to Promisekit itself :)

@implementation PMKArray (AllowSerialization)

+(BOOL) supportsSecureCoding
{
    return YES;
}

-(void) encodeWithCoder:(NSCoder*) coder
{
    [coder encodeInteger:self->count forKey:@"count"];
    for(NSUInteger c=0; c<self->count; c++)
        [coder encodeObject:self->objs[c] forKey:[NSString stringWithFormat:@"%@", @(c)]];
}

-(instancetype) initWithCoder:(NSCoder*) coder
{
    self = [self init];
    self->count = [coder decodeIntegerForKey:@"count"];
    for(NSUInteger c=0; c<self->count; c++)
        self->objs[c] = [coder decodeObjectForKey:[NSString stringWithFormat:@"%@", @(c)]];
    return self;
}

@end

Activity

  1. RomanPodymov commented on Sep 28, 2026

    @RomanPodymov
    Collaborator

    Hello @tmolitor-stud-tu
    Thanks for offering this! Persisting PMKArray seems useful for apps that need it, though I’m not sure yet how broadly it would be used in PromiseKit itself.
    The proposed implementation also needs a closer look at secure decoding: supportsSecureCoding returns YES, but decodeObjectForKey: does not restrict the classes it can decode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions