You need to sign in to do that
Don't have an account?

Native iOS development in Swift- how to post a comment using SFRestRequest and Chatter API?
In Objective C, I follow the steps as outlined here and it works fine: https://developer.salesforce.com/docs/atlas.en-us.noversion.mobile_sdk.meta/mobile_sdk/ios_rest_apis_using_methods.htm?search_text=forceios
But when following the same steps translating the code into Swift, I run into an issue with the SFRestRequest initializer, whose signature is below:
As you can see, queryParams takes a Swift Dictionary with a key and value of the String type. But when you follow the example, it seems you end up with a Dictionary with a key of the String type and value of the Dictionary type; and thus we have a type mismatch.
This doesn't seem to be a problem in Objective C, because upon inspection of the method signature in SFRestRequest.m, queryParams appears to be able to take a generic NSDictionary:
For reference here is the Swift code I'm trying out:
But unwrapping queryParams fails and resolves to nil. Trying to forcefully cast queryParams to [String:String] does not work either, and just causes a crash.
How might I get around this?
But when following the same steps translating the code into Swift, I run into an issue with the SFRestRequest initializer, whose signature is below:
Public convenience init(method: SFRestMethod, path: String, queryParams: [String : String]?)
As you can see, queryParams takes a Swift Dictionary with a key and value of the String type. But when you follow the example, it seems you end up with a Dictionary with a key of the String type and value of the Dictionary type; and thus we have a type mismatch.
This doesn't seem to be a problem in Objective C, because upon inspection of the method signature in SFRestRequest.m, queryParams appears to be able to take a generic NSDictionary:
+ (instancetype)requestWithMethod:(SFRestMethod)method path:(NSString *)path queryParams:(NSDictionary *)queryParams
For reference here is the Swift code I'm trying out:
//build the queryParams dictionary from a JSON String let body: String = "{ \"body\" :{\"messageSegments\" :[{ \"type\" : \"Text\",\"text\" : \"My Comment\"}]}}" let queryParams = SFJsonUtils.objectFromJSONString(body) as! [String:AnyObject] //construct and send the request let request = SFRestRequest(method: SFRestMethod.POST, path: "/services/data/v36.0/connect/communities/my_community_ID/chatter/feed-elements/my_element_ID/capabilities/comments/items", queryParams: queryParams as? [String:String]) SFRestAPI.sharedInstance().send(request, delegate: self)
But unwrapping queryParams fails and resolves to nil. Trying to forcefully cast queryParams to [String:String] does not work either, and just causes a crash.
How might I get around this?
Below are my Objective-C interface/implementation files:
SFRestRequestSending.h:
SFRestRequestSending.m:
Replace "My_Project_Name" with the name of your Xcode project, as specified in the stack overflow directions.
Then, from swift, I would call this class like:
All Answers
Are you abel to share your objective-c class please?
Below are my Objective-C interface/implementation files:
SFRestRequestSending.h:
SFRestRequestSending.m:
Replace "My_Project_Name" with the name of your Xcode project, as specified in the stack overflow directions.
Then, from swift, I would call this class like:
Oh yes, many thanks, you saved my day. Not sure why this is not sorted in v5.0. Anyhow, able to use it now via this method. Thanks again.
https://apkwallet.com/turbo-bomber-apk-download/
turbo bomber apk (https://apkwallet.com/turbo-bomber-apk-download/)
Good info
Self Respect Quotes That Will Highlight Your Worth (https://www.wewishes.com/self-respect-quotes-that-will-highlight-your-worth/)
Michael Jackson Quotes To Rock And Roll Your Life (https://www.wewishes.com/michael-jackson-quotes-to-rock-and-roll-your-life/)
Where to Buy Chocolate Covered Strawberries (https://www.wewishes.com/where-to-buy-chocolate-covered-strawberries/)
Whatsapp Status (https://statuswhatsapp.co/whatsapp-status/)
Attitude Status (https://bloggingmafiya.com/attitude-status/)
100+ Best Instagram Caption (https://bloggingmafiya.com/instagram-caption/)
200+ Best caption For Instagram (https://bloggingmafiya.com/caption-for-instagram/)
300+ Love Status In Hindi (https://bloggingmafiya.com/love-status-in-hindi/)
Life Quotes That'll Motivate You to Take That Next Step. Refocus and recharge with these inspirational sayings. 'What are you doing for others?' The quality, not the longevity, of one's life, is what is important. Life imitates art far more than Art imitates Life. Find ecstasy in life; the mere sense of living is joy enough.
statuswhatsapp.co
bloggingmafiya.com
icetutor.com
https://latestcelebsbio.com/
WhatsApp Status Video Download (https://www.whatsappstatusvideodownload.net/)
Apne To Apne Hote Hai (https://www.whatsappstatusvideodownload.net/2021/06/apne-to-apne-hote-hai-status.html)
Tujhse Naraz Nahi Zindagi (https://www.whatsappstatusvideodownload.net/2021/05/tujhse-naraz-nahi-zindagi-status-download.html)
Thoda Thoda Pyar Hau Tumse Status (https://www.whatsappstatusvideodownload.net/2021/04/thoda-thoda-pyar-hua-tumse-whatsapp-status.html)
Jaan Nisar Hai Status (https://www.whatsappstatusvideodownload.net/2021/06/jaan-nisar-hai-status-download.html)
http://Lo Safar Shuru Ho Gaya Status
Tera Fitoor (https://www.whatsappstatusvideodownload.net/2021/07/tera-fitoor-whatsapp-status-video.html)