pEpObjCAdapter/NSDictionary+Extension.m
author Dirk Zimmermann <dirk@pep-project.org>
Thu, 17 May 2018 09:33:33 +0200
changeset 616 9e50cc7cd612
parent 498 11b4ce5ebd2d
child 622 5c5d267a32a0
permissions -rw-r--r--
IOSAD-93 consistently using precomposedStringWithCanonicalMapping, stringWithUTF8String
dirk@215
     1
//
dirk@215
     2
//  NSDictionary+Extension.m
dirk@215
     3
//  pEpObjCAdapter
dirk@215
     4
//
dirk@215
     5
//  Created by Dirk Zimmermann on 04.09.17.
dirk@215
     6
//  Copyright © 2017 p≡p. All rights reserved.
dirk@215
     7
//
dirk@215
     8
dirk@215
     9
#import <Foundation/Foundation.h>
dirk@215
    10
dirk@215
    11
#import "NSDictionary+Extension.h"
dirk@215
    12
dirk@367
    13
#import "PEPMessageUtil.h"
dirk@225
    14
dirk@215
    15
@implementation NSDictionary (Extension)
dirk@215
    16
dirk@227
    17
- (PEP_comm_type)commType
dirk@227
    18
{
dirk@227
    19
    NSNumber *ctNum = self[kPepCommType];
dirk@227
    20
    if (!ctNum) {
dirk@227
    21
        return PEP_ct_unknown;
dirk@227
    22
    }
dirk@227
    23
    return ctNum.intValue;
dirk@227
    24
}
dirk@227
    25
dirk@216
    26
- (void)debugSaveToFilePath:(NSString * _Nonnull)filePath
dirk@215
    27
{
dirk@216
    28
    NSFileManager *fileManager = [NSFileManager defaultManager];
dirk@216
    29
    NSURL *parentPath = [[fileManager
dirk@227
    30
                          URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]
dirk@227
    31
                         firstObject];
dirk@216
    32
dirk@215
    33
    NSDate *now = [NSDate date];
dirk@215
    34
    NSString *nowDesc = [now description];
dirk@216
    35
    NSString *fileName = [NSString stringWithFormat:@"%@_%@.%@",
dirk@216
    36
                          filePath, nowDesc, @"plist"];
dirk@216
    37
dirk@216
    38
    NSURL *writeURL = [NSURL fileURLWithPath:fileName relativeToURL:parentPath];
dirk@218
    39
    NSLog(@"debugSaveToFilePath: writing %@", writeURL);
dirk@216
    40
    [self writeToURL:writeURL atomically:YES];
dirk@215
    41
}
dirk@215
    42
dirk@215
    43
@end