Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use scalar properties for primitive data types #379

Open
darkwood-studios opened this issue Nov 20, 2018 · 3 comments
Open

Use scalar properties for primitive data types #379

darkwood-studios opened this issue Nov 20, 2018 · 3 comments

Comments

@darkwood-studios
Copy link

Hi there,

the generated classes do have the NSNumber type for bool an double values. In xcode there is a way to check "Use scalar properties for primitive data types" - is there a way to realize this with mogenerator, too?

I want to use model.isCkecked = YES to set the value for a bool.

@atomicbird
Copy link
Collaborator

You didn't say what language you're using, but since you use YES rather than true it looks like you mean Objective-C.

With ObjC, your generated code should include a property called isCheckedValue of type BOOL, which you can use as you describe. If you're actually using Swift, this change is coming in the delayed-but-not-forgotten swift42 branch of this project.

@darkwood-studios
Copy link
Author

Thank for your fast answer. I'm using objective-c.

It's a huge project with an existing core data with a huge amount of entities and classes.

I want to migrate to generated files from mogenerator - but I don't want to change all lines of codes from (example) isChecked to isCheckedValue - is here a way to use this optionals as I did before?

@atomicbird
Copy link
Collaborator

You can get what you describe but only if the isChecked property is configured to use scalar types and is not configured as "optional" in the data model.

screen shot 2018-11-23 at 3 31 39 pm

If the attribute meets both of those requirements, you can then add --template-var scalarsWhenNonOptional=true as one of the arguments when running mogenerator. Then you'll get the following generated property:

@property (atomic) BOOL isChecked;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants