Remove an unused class.
This commit is contained in:
1 parent
c44e74d193
commit
be30acd177
3 files changed
-275
No files matched your search
@@ -1,49 +0,0 @@
|
||||
//
|
||||
// XMLReader.h
|
||||
//
|
||||
// Downloaded from https://github.com/cbpowell/XML-to-NSDictionary
|
||||
// Originally from http://troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter/
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XMLReader : NSObject <NSXMLParserDelegate> {
|
||||
|
||||
NSMutableArray *dictionaryStack;
|
||||
NSMutableString *textInProgress;
|
||||
NSError * __autoreleasing *errorPointer;
|
||||
}
|
||||
|
||||
+ (nullable NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)errorPointer;
|
||||
+ (nullable NSDictionary *)dictionaryForXMLString:(NSString *)string error:(NSError **)errorPointer;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSDictionary (XMLReaderNavigation)
|
||||
|
||||
- (nullable id)retrieveForPath:(NSString *)navPath;
|
||||
- (nullable NSArray *)retrieveArrayForPath:(NSString *)navPath;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,220 +0,0 @@
|
||||
//
|
||||
// XMLReader.m
|
||||
//
|
||||
// Downloaded from https://github.com/cbpowell/XML-to-NSDictionary
|
||||
// Originally from http://troybrant.net/blog/2010/09/simple-xml-to-nsdictionary-converter/
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#import "XMLReader.h"
|
||||
|
||||
NSString *const kXMLReaderTextNodeKey = @"text";
|
||||
|
||||
@interface XMLReader (Internal)
|
||||
|
||||
- (instancetype)initWithError:(NSError **)error;
|
||||
- (NSDictionary *)objectWithData:(NSData *)data;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSDictionary (XMLReaderNavigation)
|
||||
|
||||
- (id)retrieveForPath:(NSString *)navPath {
|
||||
|
||||
// Split path on dots
|
||||
NSArray *pathItems = [navPath componentsSeparatedByString:@"."];
|
||||
|
||||
// Enumerate through array
|
||||
NSEnumerator *e = [pathItems objectEnumerator];
|
||||
NSString *path;
|
||||
|
||||
// Set first branch from self
|
||||
id branch = self[[e nextObject]];
|
||||
int count = 1;
|
||||
while (path = [e nextObject]) {
|
||||
|
||||
// Check if this branch is an NSArray
|
||||
if ([branch isKindOfClass:[NSArray class]]) {
|
||||
|
||||
if ([path isEqualToString:@"last"]) {
|
||||
branch = [branch lastObject];
|
||||
} else {
|
||||
if ([branch count] > path.intValue) {
|
||||
branch = branch[path.intValue];
|
||||
} else {
|
||||
branch = nil;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
//branch is assumed to be an NSDictionary
|
||||
branch = branch[path];
|
||||
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
- (NSArray *)retrieveArrayForPath:(NSString *)navPath {
|
||||
NSObject *r = [self retrieveForPath:navPath];
|
||||
if ([r isKindOfClass:[NSDictionary class]]) {
|
||||
return @[r];
|
||||
} else {
|
||||
return (NSArray *) r;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation XMLReader
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Public methods
|
||||
|
||||
+ (NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError * __autoreleasing *)error {
|
||||
|
||||
XMLReader *reader = [[XMLReader alloc] initWithError:error];
|
||||
NSDictionary *rootDictionary = [reader objectWithData:data];
|
||||
return rootDictionary;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)dictionaryForXMLString:(NSString *)string error:(NSError * __autoreleasing *)error {
|
||||
|
||||
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
|
||||
return [XMLReader dictionaryForXMLData:data error:error];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Parsing
|
||||
|
||||
- (instancetype)initWithError:(NSError * __autoreleasing *)error {
|
||||
|
||||
if (self = [super init]) {
|
||||
|
||||
errorPointer = error;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (NSDictionary *)objectWithData:(NSData *)data {
|
||||
|
||||
// Clear out any old data
|
||||
|
||||
dictionaryStack = [[NSMutableArray alloc] init];
|
||||
textInProgress = [[NSMutableString alloc] init];
|
||||
|
||||
// Initialize the stack with a fresh dictionary
|
||||
[dictionaryStack addObject:[NSMutableDictionary dictionary]];
|
||||
|
||||
// Parse the XML
|
||||
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
|
||||
parser.delegate = self;
|
||||
BOOL success = [parser parse];
|
||||
|
||||
// Return the stack's root dictionary on success
|
||||
if (success){
|
||||
|
||||
NSDictionary *resultDict = dictionaryStack[0];
|
||||
|
||||
return resultDict;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark NSXMLParserDelegate methods
|
||||
|
||||
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
|
||||
|
||||
// Get the dictionary for the current level in the stack
|
||||
NSMutableDictionary *parentDict = dictionaryStack.lastObject;
|
||||
|
||||
// Create the child dictionary for the new element, and initilaize it with the attributes
|
||||
NSMutableDictionary *childDict = [NSMutableDictionary dictionary];
|
||||
[childDict addEntriesFromDictionary:attributeDict];
|
||||
|
||||
// If there's already an item for this key, it means we need to create an array
|
||||
id existingValue = parentDict[elementName];
|
||||
if (existingValue) {
|
||||
NSMutableArray *array = nil;
|
||||
if ([existingValue isKindOfClass:[NSMutableArray class]])
|
||||
{
|
||||
// The array exists, so use it
|
||||
array = (NSMutableArray *) existingValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create an array if it doesn't exist
|
||||
array = [NSMutableArray array];
|
||||
[array addObject:existingValue];
|
||||
|
||||
// Replace the child dictionary with an array of children dictionaries
|
||||
parentDict[elementName] = array;
|
||||
}
|
||||
|
||||
// Add the new child dictionary to the array
|
||||
[array addObject:childDict];
|
||||
}
|
||||
else {
|
||||
|
||||
// No existing value, so update the dictionary
|
||||
parentDict[elementName] = childDict;
|
||||
}
|
||||
|
||||
// Update the stack
|
||||
[dictionaryStack addObject:childDict];
|
||||
}
|
||||
|
||||
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
|
||||
|
||||
// Update the parent dict with text info
|
||||
NSMutableDictionary *dictInProgress = dictionaryStack.lastObject;
|
||||
|
||||
// Set the text property
|
||||
if (textInProgress.length > 0) {
|
||||
|
||||
dictInProgress[kXMLReaderTextNodeKey] = [textInProgress stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
|
||||
// Reset the text
|
||||
textInProgress = [[NSMutableString alloc] init];
|
||||
}
|
||||
|
||||
// Pop the current dict
|
||||
[dictionaryStack removeLastObject];
|
||||
}
|
||||
|
||||
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
|
||||
// Build the text value
|
||||
[textInProgress appendString:string];
|
||||
}
|
||||
|
||||
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
|
||||
// Set the error pointer to the parser's error object
|
||||
if (errorPointer)
|
||||
*errorPointer = parseError;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -98,7 +98,6 @@
|
||||
A9F5820C1DCC861F005F3E92 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9F5820B1DCC861F005F3E92 /* Assets.xcassets */; };
|
||||
A9F7F8E01837C44B0036AE7E /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9ED7B21180067A2008FD3A8 /* IOKit.framework */; };
|
||||
A9FC6FF61EF2E3280034CCED /* TheTVDBService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FC6FF51EF2E3280034CCED /* TheTVDBService.swift */; };
|
||||
CD3F2A881761A143000D4C73 /* XMLReader.m in Sources */ = {isa = PBXBuildFile; fileRef = CD3F2A871761A143000D4C73 /* XMLReader.m */; };
|
||||
CD4E6E5D12F744210095C84F /* ArtworkSelector.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD4E6E5B12F744210095C84F /* ArtworkSelector.xib */; };
|
||||
CD56963212FAAD680029FADB /* SBArtworkSelector.m in Sources */ = {isa = PBXBuildFile; fileRef = CD56963112FAAD680029FADB /* SBArtworkSelector.m */; };
|
||||
CD71FEA312F1B5AF00F0A98D /* SBMetadataSearchController.m in Sources */ = {isa = PBXBuildFile; fileRef = CD71FEA212F1B5AF00F0A98D /* SBMetadataSearchController.m */; };
|
||||
@@ -331,8 +330,6 @@
|
||||
A9F5820B1DCC861F005F3E92 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
A9FC6FF41EF2E3280034CCED /* Subler-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Subler-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
A9FC6FF51EF2E3280034CCED /* TheTVDBService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TheTVDBService.swift; path = Classes/MetadataImporters/TheTVDBService.swift; sourceTree = "<group>"; };
|
||||
CD3F2A861761A143000D4C73 /* XMLReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMLReader.h; path = Others/XMLReader.h; sourceTree = "<group>"; };
|
||||
CD3F2A871761A143000D4C73 /* XMLReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = XMLReader.m; path = Others/XMLReader.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
|
||||
CD56963012FAAD680029FADB /* SBArtworkSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBArtworkSelector.h; path = Classes/SBArtworkSelector.h; sourceTree = "<group>"; };
|
||||
CD56963112FAAD680029FADB /* SBArtworkSelector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBArtworkSelector.m; path = Classes/SBArtworkSelector.m; sourceTree = "<group>"; };
|
||||
CD56966E12FAAFA90029FADB /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
|
||||
@@ -437,8 +434,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9FC6FF41EF2E3280034CCED /* Subler-Bridging-Header.h */,
|
||||
CD3F2A861761A143000D4C73 /* XMLReader.h */,
|
||||
CD3F2A871761A143000D4C73 /* XMLReader.m */,
|
||||
32DBCF750370BD2300C91783 /* Subler_Prefix.pch */,
|
||||
A9B46A9312B79B990040517A /* ButtonToolbarItem.h */,
|
||||
A9B46A9412B79B990040517A /* ButtonToolbarItem.m */,
|
||||
@@ -891,7 +886,6 @@
|
||||
A9433A8D1F2F5C3600BB38CA /* ChapterResult.swift in Sources */,
|
||||
A9EEA5F218D65490008B54B4 /* SBOptionsViewController.m in Sources */,
|
||||
A902E1D51F29DD8900D73C17 /* SBMetadataImporter.swift in Sources */,
|
||||
CD3F2A881761A143000D4C73 /* XMLReader.m in Sources */,
|
||||
A9AB485517F0AEAC000AA72E /* SBEmptyViewController.m in Sources */,
|
||||
A9AE70E11F2F7B3D001CF27C /* MetadataHelper.swift in Sources */,
|
||||
A9A0542E1DEEC3E000D1AFA4 /* SBLanguageTransformer.m in Sources */,
|
||||
|
||||
Reference in new issue
Block a user