[SalesForce] Returning a string as part of an Apex class in an AuraEnabled Method

Here's what I'm working with:

// Client-side controller

({
    handlePress : function(component, event, helper) {
        var action = component.get("c.returnClassic");
        action.setCallback(this,function(response){
                if (response.getState() === "SUCCESS"){
                    console.log(response.getReturnValue());
                }
            });
        $A.enqueueAction(action);
    }
})

// Server-side controller

public class LightningController {

    public class Classic{
  //      @AuraEnabled
        public String s {get; set;}
        @AuraEnabled public Account a {get; set;}
        @AuraEnabled public Integer i {get; set;}

        Classic(String s, Integer i){this.s=s; this.i=i; this.a=new Account(Name='hello');}
    }

    @AuraEnabled
    public static Classic returnClassic(){
        return new Classic('one',2);
    }
}

Whenever I make the String in my class AuraEnabled, I get undefined logged in the console. Whenever the string is not AuraEnabled, the console logs the object with the integer and the account object with the name string.

It looks like someone else was able to get something similar to work:
@AuraEnabled Support for Apex Class Return Types?
Although I can't see what I'm doing differently that would prevent my code from working.

UPDATE

It seems that the issue isn't with returning a string. The issue was caused by using the letter lower-case s as the property name. Lower-case r has a similar issue, and I created a new question more specific to the issue here: Returning an object from an AuraEnabled method with properties named r or s

UPDATE 2

Passing data up to the server is difficult as well and stringifying it before sending it can help avoid some of those issues. Other people also ran into these problems and wrote about it here: sObject array parameter in Lightning causes Internal Salesforce.com Error in Apex controller

Best Answer

You can try doing what Peter Knolle mentioned in the post you referenced, to just return a JSON string that contains the data in your class, instead of returning 'Classic'. Basically you would just have to serialize your class instance

@AuraEnabled
public static String returnClassic(){
    return JSON.serialize(new Classic('one',2));
}

And then in the controller just parse the string into a Javascript object.

({
    handlePress : function(component, event, helper) {
        var action = component.get("c.returnClassic");
        action.setCallback(this,function(response){
                if (response.getState() === "SUCCESS"){
                    console.log(JSON.parse(response.getReturnValue()));
                }
            });
        $A.enqueueAction(action);
    }
})