Post

Replies

Boosts

Views

Activity

Reply to Can’t run on physical device!
I think there is a time limit on how long one can actually run the app on a physical device with a free account, I used to have a free account and after some time the app will just stop running. I believe your only option now is to run it on a simulator or buy the Developer subscription...or if you find someway to delete the current certificate and reinstall a new one...
Oct ’21
Reply to Regular Expression issue for Hexadecimal and Binary strings
Here is the code to decode hexadecimal and binary: private func decodeHexString(source: String) -> Void {         let data = Data(fromHexEncodedString: source)         let altData = Data(fromHexEncodedString: "74647374")         let string = String(data: ((data) ?? altData)!, encoding: .utf8)         // Print the result         resultOutput.text = string     }     private func decodeBinaryString(source: String) -> Void {         // Split the binary string into 8'ths         let newString = source.separate(every: 8, with: "\n")         let byteArray = newString.components(separatedBy: .whitespacesAndNewlines).compactMap {UInt8($0, radix: 2)}         if let string = String(bytes: byteArray, encoding: .utf8) {             resultOutput.text = string         } else {             displayErrorMessage(title: "Encoding", message: "Bad Binary Encoding..."); return         }     } Also, there is this extension to Data: extension Data {     // From http://stackoverflow.com/a/40278391:     init?(fromHexEncodedString string: String) {         // Convert 0 ... 9, a ... f, A ...F to their decimal value,         // return nil for all other input characters         func decodeNibble(u: UInt16) -> UInt8? {             switch(u) {             case 0x30 ... 0x39:                 return UInt8(u - 0x30)             case 0x41 ... 0x46:                 return UInt8(u - 0x41 + 10)             case 0x61 ... 0x66:                 return UInt8(u - 0x61 + 10)             default:                 return nil             }         }         self.init(capacity: string.utf16.count/2)         var even = true         var byte: UInt8 = 0         for c in string.utf16 {             guard let val = decodeNibble(u: c) else { return nil }             if even {                 byte = val << 4             } else {                 byte += val                 self.append(byte)             }             even = !even         }         guard even else { return nil }     } }
Oct ’20
Reply to Regular Expression issue for Hexadecimal and Binary strings
No, I need it to detect one or the other...Like if I enter a binary string of "01110100011001010111001101110100" which is "test" in string format, I need for the isStringBinary() boolean method run and if the string is hexadecimal, say, "74657374" which is "test" in hexadecimal, then I need the isStringHex() boolean method to run...I don't know why it is stopping at "Hexadecimal" when I insert a binary string though...I was thinking about adding a return after each detect...
Oct ’20
Reply to Regular Expression issue for Hexadecimal and Binary strings
Here is the whole code for the button action method @IBAction func btnAutoCheckString(_ sender: Any) {         let source = sourceString.text!         if isStringBinary(source: source) {             decodings.selectRow(2, inComponent: 0, animated: true)             decodeBinaryString(source: source)         }         if isStringHex(source: source) {             decodings.selectRow(1, inComponent: 0, animated: true)             decodeHexString(source: source)         }     } // Applying Claude31's methods private func isStringHex(source: String) -> Bool {         let reg = try! NSRegularExpression(pattern: "(0x)?([0-9a-fA-F]{16})")         let ran = NSRange(location: 0, length: source.count)         if (reg.firstMatch(in: source, options: [], range: ran) != nil) {             return true         }         return false     }     private func isStringBinary(source: String) -> Bool {         /*         let reg = try! NSRegularExpression(pattern: "([01]{2})")         let ran = NSRange(location: 0, length: source.count)         if (reg.firstMatch(in: source, options: [], range: ran) != nil) {             return true         }         return false         */         let chars : Set<Character> = Set(source)         let isValidBin = chars.isSubset(of: ["0", "1"]) && chars.count >= 1         return isValidBin     }
Oct ’20
Reply to Aspiring Developer
Developing on MacOS is pretty simple and straight forward, it would seem that the environment is setup so that one does not have to code much (in my opinion), one can just drag and drop features into the ViewController environment. The layouts are simple enough to use except when you get to constraining a Scrolling module. Anyway, if you really want to start learning how to program SwiftUI/Swift/Mac, iOS apps. Start with something simple. Mine starter was a payroll calculator. Anyway, start with something simple, figure out what you want your program to do, design the UI (inputs, buttons, outputs, etc) then, switch to coding the app, approach it little by little (based on your current level of understadning), and begin with plugging in your UI components to your main script file. That is how I started out learning... [ this might not be the response you are looking for but I stumbled onto this thread and had to throw in my 2 cents... ]
Sep ’20
Reply to class is not key value coding-compliant for the key mainScrollView
I tried OOPer's solution but to no avail, I have screenshot the important bits which includes the code and the main view along with the Outlet connection for UIScrollView. Everything seems to be in tack...but I don't know what's wrong...I will start another iteration of this project to test out if the view is actually broken. Edit: Cannot attach images so, I will attach the code for FirstViewController.swift import UIKit class FirstViewController: UIViewController, UIScrollViewDelegate {     // MARK: Outlet prototype initializations     @IBOutlet weak var mainScrollView: UIScrollView!        override func viewDidLoad() {         super.viewDidLoad()         // Do any additional setup after loading the view.     } // For scroll view scroll functionality     override func viewWillLayoutSubviews() {         super.viewWillLayoutSubviews()                  mainScrollView.contentSize = CGSize(width: mainScrollView.contentSize.width, height: mainScrollView.contentSize.height)         mainScrollView.decelerationRate = UIScrollView.DecelerationRate.fast     } }
Sep ’20