How to use iOS SDK SWGCustomSettings to set Custom Values


I am using dreamfactory for quite a while on iOS, and now trying to use SWGCustomSettings to set Custom Setting. But tried multiple times, neither of the following can get the value posted to backend database.
var settings = SWGCustomSettings(values:[“name”:Settings.UserStatus,“value”: status])
var settings = SWGCustomSettings(values: [Settings.UserStatus : status.description])

can anybody indicate how to setup a SWGCustomSettings object with values?

      let userAPI = SWGUserApi()
        userAPI.addHeader(Settings.kApplicationName, forKey: "X-DreamFactory-Application-Name")
        var settings = SWGCustomSettings(values:["name":Settings.UserStatus,"value": status]) //values: [Settings.UserStatus : status.description]
//        var settings = StatusCustomerSetting(status: status.description)
//        settings.UserStatus = status.description;
// = [Settings.UserStatus,status.description]
//       settings.setValue(status.description, forKey: Settings.UserStatus)
// = [Settings.UserStatus]
        userAPI.setCustomSettingsWithCompletionBlock(settings) { (success:SWGSuccess!, error:NSError!) -> Void in
            println(" Setting Status \(status) to User Profile")


What is the correct way to use this IOS sdk SWGCustomSettings ?
I did not find any tutorials on this.
Any help would be appreciated.


It should be the same as creating/updating records of any DB. For example, from the iOS SDK’s example app readme:

 *  structure of request is:
 *  {
 *      "records":[
 *          {
 *             "contactGroupId":id,
 *             "contactId":id"
 *          },
 *          {...}
 *      ]
 *  }

There are examples of the raw calls in this forum thread.


Thanks for the reply. Allow me rephrase it.
My question was how to use this sdk API to set user customer setting like in this thread:

here the setting variable must be in the format of SWGCustomSettings.

 userAPI.setCustomSettingsWithCompletionBlock(settings) { (success:SWGSuccess!, error:NSError!) -> Void in

Problem was no way to set values into it and no tutorial about this customer setting.
Thanks for your time.


Thanks for this tutorial and question. I have a specific question of iOS oc API. I would appreciate it if someone having similar experience get a time to help.
How to use get customize values set in “settings” variable?

 userAPI.setCustomSettingsWithCompletionBlock(settings) { (success:SWGSuccess!, error:NSError!) -> Void in

I opened another thread here:


anybody has experience on setCustomSettingsWithCompletionBlock ??


I recommend you check the general iOS SDK API documentation here, and try out the calls in the Live API environment here.


Thanks Jeffrey for point out the new iOS API.
I realized I was still using the previous version of SDK which contains more API wrappers.
I am wondering why old version SDK is gone? Also in the new API, there is no such customerSetting API at all, instead, replaced by a simple neat general API calls.

Currently I don’t want to update all my codes with this new sdk due to a lot of work.
I am still wondering the answer to my specific question to set a value to user’s profile.

userAPI.setCustomSettingsWithCompletionBlock(settings) { (success:SWGSuccess!, error:NSError!) -> Void in

The correponding OC code is as follows

-(void) setCustomSettingsWithCompletionBlock:(SWGCustomSettings*) body
    completionHandler: (void (^)(SWGSuccess* output, NSError* error))completionBlock{

NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/custom", basePath];

// remove format in URL if needed
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];

NSString* contentType = @"application/json";

    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
id bodyDictionary = nil;
    if(body != nil && [body isKindOfClass:[NSArray class]]){
    NSMutableArray * objs = [[NSMutableArray alloc] init];
    for (id dict in (NSArray*)body) {
        if([dict respondsToSelector:@selector(asDictionary)]) {
            [objs addObject:[(NIKSwaggerObject*)dict asDictionary]];
            [objs addObject:dict];
    bodyDictionary = objs;
else if([body respondsToSelector:@selector(asDictionary)]) {
    bodyDictionary = [(NIKSwaggerObject*)body asDictionary];
else if([body isKindOfClass:[NSString class]]) {
    bodyDictionary = body;
else if([body isKindOfClass: [NIKFile class]]) {
    contentType = @"form-data";
    bodyDictionary = body;
    NSLog(@"don't know what to do with %@", body);

if(body == nil) {
    // error
[_api dictionary:requestUrl 
 completionBlock:^(NSDictionary *data, NSError *error) {
    if (error) {
        completionBlock(nil, error);return;

    completionBlock( [[SWGSuccess alloc]initWithValues: data], nil);}];


anybody successfully has a sample code for this?