Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFX Documents Path Update + Crash Fix on selected options in Settings #211

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion netfox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = kasketis;
TargetAttributes = {
8229AD611F8FB34300A9D613 = {
Expand Down Expand Up @@ -616,6 +616,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -675,6 +676,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down
6 changes: 1 addition & 5 deletions netfox.xcodeproj/xcshareddata/xcschemes/netfox_ios.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:netfox.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
6 changes: 1 addition & 5 deletions netfox.xcodeproj/xcshareddata/xcschemes/netfox_osx.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:netfox.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
9 changes: 7 additions & 2 deletions netfox/Core/NFX.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ open class NFX: NSObject
{
NFXHTTPModelManager.sharedInstance.clear()
do {
let documentsPath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true).first!
let documentsPath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true).first! + "/nfx"
if !FileManager.default.fileExists(atPath: documentsPath) {
// Creates that folder if not exists
try? FileManager.default.createDirectory(atPath: documentsPath, withIntermediateDirectories: false, attributes: nil)
}

let filePathsArray = try FileManager.default.subpathsOfDirectory(atPath: documentsPath)
for filePath in filePathsArray {
if filePath.hasPrefix("nfx") {
Expand Down Expand Up @@ -250,7 +255,7 @@ open class NFX: NSObject

extension NFX {
fileprivate var presentingViewController: UIViewController? {
var rootViewController = UIApplication.shared.keyWindow?.rootViewController
var rootViewController = UIApplication.shared.windows.first(where: {$0.isKeyWindow })?.rootViewController
while let controller = rootViewController?.presentedViewController {
rootViewController = controller
}
Expand Down
4 changes: 2 additions & 2 deletions netfox/Core/NFXHTTPModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {

@objc public func getRequestBodyFilename() -> String
{
return String("nfx_request_body_") + "\(self.requestTime!)_\(getRandomHash() as String)"
return String("nfx/nfx_request_body_") + "\(self.requestTime!)_\(getRandomHash() as String)"
}

@objc public func getResponseBodyFilepath() -> String
Expand All @@ -187,7 +187,7 @@ fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {

@objc public func getResponseBodyFilename() -> String
{
return String("nfx_response_body_") + "\(self.requestTime!)_\(getRandomHash() as String)"
return String("nfx/nfx_response_body_") + "\(self.requestTime!)_\(getRandomHash() as String)"
}

@objc public func getDocumentsPath() -> String
Expand Down
2 changes: 1 addition & 1 deletion netfox/Core/NFXHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ struct NFXPath
{
static let Documents = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true).first! as NSString

static let SessionLog = NFXPath.Documents.appendingPathComponent("session.log");
static let SessionLog = NFXPath.Documents.appendingPathComponent("nfx/session.log");
}


Expand Down
2 changes: 1 addition & 1 deletion netfox/iOS/NFXListController_iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class NFXListController_iOS: NFXListController, UITableViewDelegate, UITableView
cell.configForObject(obj)
}
} else {
if NFXHTTPModelManager.sharedInstance.getModels().count > 0 {
if NFXHTTPModelManager.sharedInstance.getModels().count > indexPath.row {
let obj = NFXHTTPModelManager.sharedInstance.getModels()[(indexPath as NSIndexPath).row]
cell.configForObject(obj)
}
Expand Down