mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 07:34:09 +01:00
61 lines
1.1 KiB
Objective-C
Executable File
61 lines
1.1 KiB
Objective-C
Executable File
//
|
|
// RSParserInternal.m
|
|
// RSParser
|
|
//
|
|
// Created by Brent Simmons on 12/26/16.
|
|
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
|
//
|
|
|
|
#import <CommonCrypto/CommonDigest.h>
|
|
#import <RSParser/RSParserInternal.h>
|
|
|
|
|
|
static BOOL RSParserIsNil(id obj) {
|
|
|
|
return obj == nil || obj == [NSNull null];
|
|
}
|
|
|
|
BOOL RSParserObjectIsEmpty(id obj) {
|
|
|
|
if (RSParserIsNil(obj)) {
|
|
return YES;
|
|
}
|
|
|
|
if ([obj respondsToSelector:@selector(count)]) {
|
|
return [obj count] < 1;
|
|
}
|
|
|
|
if ([obj respondsToSelector:@selector(length)]) {
|
|
return [obj length] < 1;
|
|
}
|
|
|
|
return NO; /*Shouldn't get here very often.*/
|
|
}
|
|
|
|
BOOL RSParserStringIsEmpty(NSString *s) {
|
|
|
|
return RSParserIsNil(s) || s.length < 1;
|
|
}
|
|
|
|
|
|
@implementation NSDictionary (RSParserInternal)
|
|
|
|
- (nullable id)rsparser_objectForCaseInsensitiveKey:(NSString *)key {
|
|
|
|
id obj = self[key];
|
|
if (obj) {
|
|
return obj;
|
|
}
|
|
|
|
for (NSString *oneKey in self.allKeys) {
|
|
|
|
if ([oneKey isKindOfClass:[NSString class]] && [key caseInsensitiveCompare:oneKey] == NSOrderedSame) {
|
|
return self[oneKey];
|
|
}
|
|
}
|
|
|
|
return nil;
|
|
}
|
|
|
|
@end
|