M O O N R I S E avatar

SwiftyConnect - Steemconnect for iOS - More Helpers & Bugfixing

moonrise

Published: 23 Apr 2018 › Updated: 23 Apr 2018SwiftyConnect - Steemconnect for iOS - More Helpers & Bugfixing

SwiftyConnect - Steemconnect for iOS - More Helpers & Bugfixing

wallpaper.png

SwiftyConnect

Bug Fixes

What was the issue(s)?

Broadcasting comments / posts via steemconnect failed and did not work.

What was the solution?

Making the whole String Array optional instead of only the strings inside the array fixed the error

-    let links: [String?]
-    let image: [String?]
+    let links: [String]?
+    let image: [String]?

The reason behind it is when for example the links array is empty it type gets interpreted as an Any type instead of an String. Any types cannot be converted to JSON meaning the App crashes without any warning!

New Features

What feature(s) did you add?

Auth

I have improved the error output for Auth actions

          do {
                    let json = try response.responseJSON()
                    
                    if (response.response.statusCode != 200) {
                        var err_desc : String = ""
                        
                        if let desc = json["error_description"] {
                            err_desc = desc as! String
                        }
                        
                        callback([
                            "error": response.response.statusString,
                            "error_code": response.response.statusCode,
                            "error_desc": err_desc
                            ])
                        return
                    }
                    
                    callback(json)
                }
                catch let error {
                    print(error)
                    
                    callback([
                        "error": error
                    ])
                }
Helper

3 new helper functions were added.

public func validAccountName(name: String) -> String?

public func convertToCurrency(value: String, currency: String, callback:((Any?, Double?) -> Void)?)

public func getSteemAndSbdPrices(currency: String, callback:((Any?, NSDictionary?) -> Void)?)

validAccountName
Checks if an account name is valid

convertToCurrency
Converts an SBD / STEEM value to it's currency value (eg. "1 Steem" to 3 Euro)

getSteemAndSbdPrices
Fetches the latest SBD & STEEM prices from coinmarketcap

Else some small improvements and unit tests.

How did you implement it/them?

Code Changes

Installation

Carthage

github "caspernikus/SwiftyConnect" ~> 0.1.6

(When building SwiftyConnect the lib OAuth2 is also builded, there is no need to add OAuth2 inside your project, since SwiftyConenct contains OAuth2!)

Roadmap

  • V0.2:
    • Full API Unit Tests
    • Full API Documentation
  • V1.0:
    • Full Documentation
    • More Helper Class Functions
    • Transactions Sending / Receiving
    • Signing

How to contribute?

Create Pull Requests

GitHub Link

Proof for GitHub

Please visit my last contribution here, to see that benediktveith is also my account !

I am currently handicap so it takes a lot longer to add new stuff, hope y'all understand it :)



Posted on Utopian.io - Rewarding Open Source Contributors

Leave SwiftyConnect - Steemconnect for iOS - More Helpers & Bugfixing to:

Written by

<3 Music & Programming & More <3

Read more #utopian-io posts


Best Posts From M O O N R I S E

We have not curated any of moonrise's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From M O O N R I S E