From 40964f85001d1859a00384a035e353c5dee768d7 Mon Sep 17 00:00:00 2001 From: Bishal Ghimire Date: Mon, 29 Feb 2016 14:14:05 +0545 Subject: [PATCH 1/2] Local JSON Parser file added APCSharingOptionsViewController and APCWithdrawSurveyViewController use APCLocalJSONParser util method dictionaryFromJSONFileName --- .../APCAppCore.xcodeproj/project.pbxproj | 17 +++++- .../LocalJSONParser/APCLocalJSONParser.h | 40 +++++++++++++ .../LocalJSONParser/APCLocalJSONParser.m | 58 +++++++++++++++++++ .../Profile/APCProfile.storyboard | 49 +++++++++++----- .../Profile/APCSharingOptionsViewController.m | 12 ++-- .../Profile/APCWithdrawSurveyViewController.m | 10 +--- 6 files changed, 157 insertions(+), 29 deletions(-) create mode 100644 APCAppCore/APCAppCore/Library/LocalJSONParser/APCLocalJSONParser.h create mode 100644 APCAppCore/APCAppCore/Library/LocalJSONParser/APCLocalJSONParser.m diff --git a/APCAppCore/APCAppCore.xcodeproj/project.pbxproj b/APCAppCore/APCAppCore.xcodeproj/project.pbxproj index fc1ab74b..91e3be36 100644 --- a/APCAppCore/APCAppCore.xcodeproj/project.pbxproj +++ b/APCAppCore/APCAppCore.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 0595C6611C84292700210852 /* APCLocalJSONParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 0595C65F1C84292700210852 /* APCLocalJSONParser.h */; }; + 0595C6621C84292700210852 /* APCLocalJSONParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 0595C6601C84292700210852 /* APCLocalJSONParser.m */; }; 08023C4F1AA94F48008E6DDA /* APCAllSetContentViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 08023C4D1AA94F48008E6DDA /* APCAllSetContentViewController.h */; }; 08023C501AA94F48008E6DDA /* APCAllSetContentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08023C4E1AA94F48008E6DDA /* APCAllSetContentViewController.m */; }; 08023C531AAA12DF008E6DDA /* APCAllSetTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 08023C511AAA12DF008E6DDA /* APCAllSetTableViewCell.h */; }; @@ -777,6 +779,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 0595C65F1C84292700210852 /* APCLocalJSONParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCLocalJSONParser.h; sourceTree = ""; }; + 0595C6601C84292700210852 /* APCLocalJSONParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APCLocalJSONParser.m; sourceTree = ""; }; 08023C4D1AA94F48008E6DDA /* APCAllSetContentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCAllSetContentViewController.h; sourceTree = ""; }; 08023C4E1AA94F48008E6DDA /* APCAllSetContentViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APCAllSetContentViewController.m; sourceTree = ""; }; 08023C511AAA12DF008E6DDA /* APCAllSetTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APCAllSetTableViewCell.h; sourceTree = ""; }; @@ -1577,6 +1581,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0595C65E1C8428FA00210852 /* LocalJSONParser */ = { + isa = PBXGroup; + children = ( + 0595C65F1C84292700210852 /* APCLocalJSONParser.h */, + 0595C6601C84292700210852 /* APCLocalJSONParser.m */, + ); + path = LocalJSONParser; + sourceTree = ""; + }; 08027A3A1A7319AC00B358CC /* Assets */ = { isa = PBXGroup; children = ( @@ -2424,6 +2437,7 @@ F5B947341A73272C0034C522 /* Library */ = { isa = PBXGroup; children = ( + 0595C65E1C8428FA00210852 /* LocalJSONParser */, 5B0601BF1AE79AE0009D6D65 /* FeedParser */, F5B947351A73272C0034C522 /* AppearanceHelpers */, F5B9473C1A73272C0034C522 /* AssertionHandler */, @@ -3402,6 +3416,7 @@ F5F12AD21A2F78490015982C /* APCAddressTableViewCell.h in Headers */, F5F12ADC1A2F78490015982C /* APCSegmentedTableViewCell.h in Headers */, F5F129E21A2F78490015982C /* APCDataMonitor+Bridge.h in Headers */, + 0595C6611C84292700210852 /* APCLocalJSONParser.h in Headers */, F5B947D31A73272C0034C522 /* UIScrollView+Helper.h in Headers */, F5F12A811A2F78490015982C /* APCPresentAnimator.h in Headers */, F5B9462B1A7309A20034C522 /* ZZConstants.h in Headers */, @@ -3882,6 +3897,7 @@ F5B947C61A73272C0034C522 /* NSManagedObject+APCHelper.m in Sources */, F5B947DC1A73272C0034C522 /* APCLog.m in Sources */, 08023C501AA94F48008E6DDA /* APCAllSetContentViewController.m in Sources */, + 0595C6621C84292700210852 /* APCLocalJSONParser.m in Sources */, F5F12AD31A2F78490015982C /* APCAddressTableViewCell.m in Sources */, F5F12A701A2F78490015982C /* APCCircularProgressView.m in Sources */, 5B827B611A81CAE200C685A3 /* APCDashboardTableViewCell.m in Sources */, @@ -3895,7 +3911,6 @@ F5B9480D1A73272C0034C522 /* APCScheduleExpressionTokenizer.m in Sources */, 6C7346091A7ECD3B00DA9CD8 /* APCConsentTaskViewController.m in Sources */, EE64F4321B02517000A402A7 /* APCOnboardingManager.m in Sources */, - F54DDD281A8026010073E4B4 /* APCDataTracker.m in Sources */, F5F12A7A1A2F78490015982C /* APCAxisView.m in Sources */, 6CD8B6751AC5011D0061E6D6 /* APCTaskReminder.m in Sources */, F5B947EC1A73272C0034C522 /* APCDebugWindow.m in Sources */, diff --git a/APCAppCore/APCAppCore/Library/LocalJSONParser/APCLocalJSONParser.h b/APCAppCore/APCAppCore/Library/LocalJSONParser/APCLocalJSONParser.h new file mode 100644 index 00000000..47b9e80c --- /dev/null +++ b/APCAppCore/APCAppCore/Library/LocalJSONParser/APCLocalJSONParser.h @@ -0,0 +1,40 @@ +// +// APCLocalJSONParser.h +// APCAppCore +// +// Copyright (c) 2015, Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder(s) nor the names of any contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. No license is granted to the trademarks of +// the copyright holders even if such marks are included in this software. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#import + +@interface APCLocalJSONParser : NSObject + ++ (NSDictionary *)dictionaryFromJSONFileName:(NSString *)jsonFileName; + +@end diff --git a/APCAppCore/APCAppCore/Library/LocalJSONParser/APCLocalJSONParser.m b/APCAppCore/APCAppCore/Library/LocalJSONParser/APCLocalJSONParser.m new file mode 100644 index 00000000..363a415c --- /dev/null +++ b/APCAppCore/APCAppCore/Library/LocalJSONParser/APCLocalJSONParser.m @@ -0,0 +1,58 @@ +// +// APCLocalJSONParser.m +// APCAppCore +// +// Copyright (c) 2015, Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation and/or +// other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder(s) nor the names of any contributors +// may be used to endorse or promote products derived from this software without +// specific prior written permission. No license is granted to the trademarks of +// the copyright holders even if such marks are included in this software. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + + +#import "APCLocalJSONParser.h" +#import "APCLog.h" + +@implementation APCLocalJSONParser + ++ (NSDictionary *)dictionaryFromJSONFileName:(NSString *)jsonFileName +{ + NSString *filePath = [[NSBundle mainBundle] pathForResource:jsonFileName ofType:@"json"]; + NSAssert(filePath != nil, @"Unable to location file with Consent Section in main bundle"); + + NSString *JSONString = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL]; + + NSError *parseError = nil; + NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:[JSONString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&parseError]; + + if (jsonDictionary != nil) { + return jsonDictionary; + } else { + APCLogError2(parseError); + return nil; + } +} + +@end diff --git a/APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfile.storyboard b/APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfile.storyboard index e16048a7..533acc5d 100644 --- a/APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfile.storyboard +++ b/APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfile.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -119,7 +120,7 @@ - + - + - + + + - + - + @@ -252,8 +255,10 @@ + +