IOS-559 better NSDictionary.dumpReferences
authorDirk Zimmermann <dirk@pep-project.org>
Thu, 07 Jun 2018 11:12:18 +0200
changeset 623fade443297e3
parent 622 5c5d267a32a0
child 624 fb142cf04649
IOS-559 better NSDictionary.dumpReferences
pEpObjCAdapter/NSDictionary+Debug.h
pEpObjCAdapter/NSDictionary+Debug.m
     1.1 --- a/pEpObjCAdapter/NSDictionary+Debug.h	Thu Jun 07 10:08:17 2018 +0200
     1.2 +++ b/pEpObjCAdapter/NSDictionary+Debug.h	Thu Jun 07 11:12:18 2018 +0200
     1.3 @@ -15,4 +15,9 @@
     1.4   */
     1.5  - (void)debugSaveToFilePath:(NSString * _Nonnull)filePath;
     1.6  
     1.7 +/**
     1.8 + Treating this object as a pEp messages, find out the references and print them (for debugging).
     1.9 + */
    1.10 +- (void)dumpReferences;
    1.11 +
    1.12  @end
     2.1 --- a/pEpObjCAdapter/NSDictionary+Debug.m	Thu Jun 07 10:08:17 2018 +0200
     2.2 +++ b/pEpObjCAdapter/NSDictionary+Debug.m	Thu Jun 07 11:12:18 2018 +0200
     2.3 @@ -29,4 +29,20 @@
     2.4      [self writeToURL:writeURL atomically:YES];
     2.5  }
     2.6  
     2.7 +- (void)dumpReferences
     2.8 +{
     2.9 +    NSString *messageID = [self valueForKey:kPepID];
    2.10 +    if (messageID == nil) {
    2.11 +        messageID = @"unknown";
    2.12 +    }
    2.13 +    NSArray *references = [self valueForKey:kPepReferences];
    2.14 +    if (references.count > 0) {
    2.15 +        for (NSString *ref in references) {
    2.16 +            NSLog(@"messageID %@ -> ref %@\n", messageID, ref);
    2.17 +        }
    2.18 +    } else {
    2.19 +        NSLog(@"messageID %@ -> no refs\n", messageID);
    2.20 +    }
    2.21 +}
    2.22 +
    2.23  @end