Mantle

Mantle

Model framework for Cocoa and Cocoa Touch

Member Since 7 years ago

Experience Points
0
follower
Lessons Completed
0
follow
Best Reply Awards
2
repos
Activity
Jan
23
4 days ago
started
started time in 3 days ago
Jan
21
6 days ago
Activity icon
issue

joaodforce issue comment Mantle/Mantle

joaodforce
joaodforce

Handling null values when mapping to a BOOL property

In my MTLModel class I have the following property:

@property (assign) bool FuncionarioPodeLancar;

Its a basic type boolean, when the back end sends true or false on the JSON object, it all works as expected, however Ive noticed that many times it returns null instead of actual false. IMO its bad practice from the back end team, but the issue is very widespread on my project, so I would expect to treat null as false.

Mantle however, when dealing with this just fails the JSON Decoding.

*** Caught exception setting key "FuncionarioPodeLancar" : [<MotivoAusencia 0x600000271a00> setNilValueForKey]: could not set nil as the value for the key FuncionarioPodeLancar.

It fails with an attempt to insert nil into the value.

Is it possible to treat this by modifying my model whilst keeping in boolean? I attempted to create a custom valueTransformer, however it seems like it is not possible to use a valueTransformer to return basic types, only pointers.

Maybe this should be fixed on the library itself?

joaodforce
joaodforce

Feel free to reopen if the NSNumber-based approach doesn't work.

I made a value transformer like this and it worked. Thanks a lot.

+ (NSValueTransformer *)nullableBooleanTransformer {
    return [MTLValueTransformer transformerUsingForwardBlock:^id(NSNumber *val, BOOL *success, NSError *__autoreleasing *error) {
        if (val == nil || [val isEqual:[NSNull null]]) {
            return @(NO);
        }
        return val;
    } reverseBlock:^id(NSNumber *val, BOOL *success, NSError *__autoreleasing *error) {
        return val;
    }];
}
Jan
20
1 week ago
Activity icon
issue

robb issue comment Mantle/Mantle

robb
robb

Handling null values when mapping to a BOOL property

In my MTLModel class I have the following property:

@property (assign) bool FuncionarioPodeLancar;

Its a basic type boolean, when the back end sends true or false on the JSON object, it all works as expected, however Ive noticed that many times it returns null instead of actual false. IMO its bad practice from the back end team, but the issue is very widespread on my project, so I would expect to treat null as false.

Mantle however, when dealing with this just fails the JSON Decoding.

*** Caught exception setting key "FuncionarioPodeLancar" : [<MotivoAusencia 0x600000271a00> setNilValueForKey]: could not set nil as the value for the key FuncionarioPodeLancar.

It fails with an attempt to insert nil into the value.

Is it possible to treat this by modifying my model whilst keeping in boolean? I attempted to create a custom valueTransformer, however it seems like it is not possible to use a valueTransformer to return basic types, only pointers.

Maybe this should be fixed on the library itself?

robb
robb

I think a more idiomatic way would be to implement a validation method and assign whatever value you see fit.

Activity icon
issue

robb issue comment Mantle/Mantle

robb
robb

Handling null values when mapping to a BOOL property

In my MTLModel class I have the following property:

@property (assign) bool FuncionarioPodeLancar;

Its a basic type boolean, when the back end sends true or false on the JSON object, it all works as expected, however Ive noticed that many times it returns null instead of actual false. IMO its bad practice from the back end team, but the issue is very widespread on my project, so I would expect to treat null as false.

Mantle however, when dealing with this just fails the JSON Decoding.

*** Caught exception setting key "FuncionarioPodeLancar" : [<MotivoAusencia 0x600000271a00> setNilValueForKey]: could not set nil as the value for the key FuncionarioPodeLancar.

It fails with an attempt to insert nil into the value.

Is it possible to treat this by modifying my model whilst keeping in boolean? I attempted to create a custom valueTransformer, however it seems like it is not possible to use a valueTransformer to return basic types, only pointers.

Maybe this should be fixed on the library itself?

robb
robb

Feel free to reopen if the NSNumber-based approach doesn't work.

Activity icon
issue

robb issue Mantle/Mantle

robb
robb

Handling null values when mapping to a BOOL property

In my MTLModel class I have the following property:

@property (assign) bool FuncionarioPodeLancar;

Its a basic type boolean, when the back end sends true or false on the JSON object, it all works as expected, however Ive noticed that many times it returns null instead of actual false. IMO its bad practice from the back end team, but the issue is very widespread on my project, so I would expect to treat null as false.

Mantle however, when dealing with this just fails the JSON Decoding.

*** Caught exception setting key "FuncionarioPodeLancar" : [<MotivoAusencia 0x600000271a00> setNilValueForKey]: could not set nil as the value for the key FuncionarioPodeLancar.

It fails with an attempt to insert nil into the value.

Is it possible to treat this by modifying my model whilst keeping in boolean? I attempted to create a custom valueTransformer, however it seems like it is not possible to use a valueTransformer to return basic types, only pointers.

Maybe this should be fixed on the library itself?

Activity icon
issue

robb issue comment Mantle/Mantle

robb
robb

Handling null values when mapping to a BOOL property

In my MTLModel class I have the following property:

@property (assign) bool FuncionarioPodeLancar;

Its a basic type boolean, when the back end sends true or false on the JSON object, it all works as expected, however Ive noticed that many times it returns null instead of actual false. IMO its bad practice from the back end team, but the issue is very widespread on my project, so I would expect to treat null as false.

Mantle however, when dealing with this just fails the JSON Decoding.

*** Caught exception setting key "FuncionarioPodeLancar" : [<MotivoAusencia 0x600000271a00> setNilValueForKey]: could not set nil as the value for the key FuncionarioPodeLancar.

It fails with an attempt to insert nil into the value.

Is it possible to treat this by modifying my model whilst keeping in boolean? I attempted to create a custom valueTransformer, however it seems like it is not possible to use a valueTransformer to return basic types, only pointers.

Maybe this should be fixed on the library itself?

robb
robb

I attempted to create a custom valueTransformer, however it seems like it is not possible to use a valueTransformer to return basic types, only pointers.

You can return an NSNumber and Key-Value-Coding will do the right thing.

Jan
19
1 week ago
Activity icon
issue

mkjhgfdsa123 issue comment Mantle/Mantle

mkjhgfdsa123
mkjhgfdsa123

Handling null values when mapping to a BOOL property

In my MTLModel class I have the following property:

@property (assign) bool FuncionarioPodeLancar;

Its a basic type boolean, when the back end sends true or false on the JSON object, it all works as expected, however Ive noticed that many times it returns null instead of actual false. IMO its bad practice from the back end team, but the issue is very widespread on my project, so I would expect to treat null as false.

Mantle however, when dealing with this just fails the JSON Decoding.

*** Caught exception setting key "FuncionarioPodeLancar" : [<MotivoAusencia 0x600000271a00> setNilValueForKey]: could not set nil as the value for the key FuncionarioPodeLancar.

It fails with an attempt to insert nil into the value.

Is it possible to treat this by modifying my model whilst keeping in boolean? I attempted to create a custom valueTransformer, however it seems like it is not possible to use a valueTransformer to return basic types, only pointers.

Maybe this should be fixed on the library itself?

mkjhgfdsa123
mkjhgfdsa123

诚聘网络兼职工资日结!还不~错详情请登陆招聘网站http://brhlqvy.cn?9

Activity icon
issue

joaodforce issue Mantle/Mantle

joaodforce
joaodforce

Handling null values when mapping to a BOOL property

In my MTLModel class I have the following property:

@property (assign) bool FuncionarioPodeLancar;

Its a basic type boolean, when the back end sends true or false on the JSON object, it all works as expected, however Ive noticed that many times it returns null instead of actual false. IMO its bad practice from the back end team, but the issue is very widespread on my project, so I would expect to treat null as false.

Mantle however, when dealing with this just fails the JSON Decoding.

*** Caught exception setting key "FuncionarioPodeLancar" : [<MotivoAusencia 0x600000271a00> setNilValueForKey]: could not set nil as the value for the key FuncionarioPodeLancar.

It fails with an attempt to insert nil into the value.

Is it possible to treat this by modifying my model whilst keeping in boolean? I attempted to create a custom valueTransformer, however it seems like it is not possible to use a valueTransformer to return basic types, only pointers.

Maybe this should be fixed on the library itself?

started
started time in 1 week ago
Jan
18
1 week ago
started
started time in 1 week ago
started
started time in 1 week ago
Jan
8
2 weeks ago
started
started time in 2 weeks ago
Jan
1
3 weeks ago
started
started time in 3 weeks ago
Dec
23
1 month ago
started
started time in 1 month ago
started
started time in 1 month ago
Dec
22
1 month ago
started
started time in 1 month ago
Dec
20
1 month ago
started
started time in 1 month ago
Dec
18
1 month ago
Activity icon
issue

github-actions[bot] issue Mantle/Mantle

github-actions[bot]
github-actions[bot]

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

Dec
16
1 month ago
Activity icon
fork

liaowei-zsxq forked Mantle/Mantle

⚡ Model framework for Cocoa and Cocoa Touch
liaowei-zsxq Updated
fork time in 1 month ago
started
started time in 1 month ago
Dec
13
1 month ago
Activity icon
issue

robb issue comment Mantle/Mantle

robb
robb

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

Dec
12
1 month ago
Activity icon
issue

JanGorman issue comment Mantle/Mantle

JanGorman
JanGorman

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

JanGorman
JanGorman

@robb Indeed, was just about to comment 😬. I manually pushed it since the ${GITHUB_REF/refs\/tags\//} doesn't resolve to the right thing if run from master. The next version should be ok though. The COCOAPODS_TRUNK_TOKEN is up to date.

Activity icon
issue

robb issue comment Mantle/Mantle

robb
robb

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

robb
robb

I think @JanGorman just released a new pod – @shmueldw can you confirm it's working and close out the issue?

Activity icon
issue

robb issue Mantle/Mantle

robb
robb

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

Dec
11
1 month ago
Activity icon
issue

mkjhgfdsa123 issue comment Mantle/Mantle

mkjhgfdsa123
mkjhgfdsa123

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

mkjhgfdsa123
mkjhgfdsa123

诚聘网络兼职工资日结!还不~错详情请登陆招聘网站http://brhlqvy.cn?9

Activity icon
issue

github-actions[bot] issue Mantle/Mantle

github-actions[bot]
github-actions[bot]

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

Dec
9
1 month ago
started
started time in 1 month ago
Dec
8
1 month ago
started
started time in 1 month ago
Dec
6
1 month ago
Activity icon
issue

JanGorman issue comment Mantle/Mantle

JanGorman
JanGorman

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

JanGorman
JanGorman

I just remembered that there was an issue with CocoaPods in April that required everyone to log in again and/or regenerate their COCOAPODS_TRUNK_TOKEN: https://blog.cocoapods.org/CocoaPods-Trunk-RCE/

I have a ruby env setup, I can dig further sometime in the coming days.

Activity icon
issue

robb issue comment Mantle/Mantle

robb
robb

Can't install version 2.2.0 using pods

Hi, I can't install Mantle version 2.2.0 using pods.

[!] CocoaPods could not find compatible versions for pod "Mantle": In Podfile: *** (from ../***) was resolved to 1.1.0.1101, which depends on Mantle (= 2.2.0)

None of your spec sources contain a spec satisfying the dependency: Mantle (= 2.2.0).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

The latest version that I able to install using pods is 2.1.6

Please help.

robb
robb

IIRC I looked into this briefly but I ran into problems getting the spec to validate.

I don't have a ruby environment set up and the Cocoapods app's bundled pod seems to be too old.

Previous