SwiftyConnect - Steemconnect for iOS - More Helpers & Bugfixing

in #utopian-io6 years ago (edited)

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

Sort:  

That's pretty, I wonder why don't you use AnyObject instead of Any.
And while you implement comments I just want to remind comment_options in case if you forget it somehow. https://github.com/steemit/steem-js/blob/09213cb7954ec849bf2db4592a57ae0e0def9950/test/comment.test.js#L21-L57

Hey man,
Honestly I forgot about comment_options... thanks for mentioning them. I will add them directly into the next update!

Also there is no big reason that I am using Any instead of AnyObject. AnyObject is just more specific and I am unsure if it could lead to errors, so I have chosen Any.

But I am open to enhancements, so I will check if AnyObject could make sense :))

Sounds nice, I once tried to do it for steem API, I just couldn't handle those JSON responses and those many optionals :) I hope it won't bother you on your journey.

I'm already using this and its amazing. Now that posting is fixed, I'm loving this more by the second.

Thanks for the contribution. It has been approved.


Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Nice one, please how do i contact you via email or discord @moonrise

Steemconnect Discord and then write a direct message to moonrise

Hey @moonrise! Thank you for the great work you've done!

We're already looking forward to your next contribution!

Fully Decentralized Rewards

We hope you will take the time to share your expertise and knowledge by rating contributions made by others on Utopian.io to help us reward the best contributions together.

Utopian Witness!

Vote for Utopian Witness! We are made of developers, system administrators, entrepreneurs, artists, content creators, thinkers. We embrace every nationality, mindset and belief.

Want to chat? Join us on Discord https://discord.me/utopian-io

Coin Marketplace

STEEM 0.15
TRX 0.15
JST 0.028
BTC 53912.73
ETH 2234.17
USDT 1.00
SBD 2.30