Code Monkey home page Code Monkey logo

Comments (4)

DoctorG avatar DoctorG commented on June 15, 2024

It's the same thing

Sent from my iPhone 5s

On Jul 19, 2014, at 1:49 PM, Yanni Mitis [email protected] wrote:

I think you want:

if (self.initialSelections.count > 0)

instead of:

if (self.initialSelections)

or only initialize the array in the initWithTitle method if intialSelections is not nill:

if(initialSelections != nil)
{
   self.initialSelections = [[NSArray alloc] initWithArray:initialSelections];
}


Reply to this email directly or view it on GitHub.

from actionsheetpicker-3.0.

yannify avatar yannify commented on June 15, 2024

How is it the same thing?

The way its currenltly written:

if(self.initializeSelections)

Will always evaluate to true, then the asserts within the if block will
fail if the initializeSelections array has a count of zero.

...
Actually, probably want:

if (self.initialSelections && self.initialSelections.count > 0)

to be safer.

On Sat, Jul 19, 2014 at 10:58 AM, Gregory P. Moore, MD <
[email protected]> wrote:

It's the same thing

Sent from my iPhone 5s

On Jul 19, 2014, at 1:49 PM, Yanni Mitis [email protected]
wrote:

I think you want:

if (self.initialSelections.count > 0)

instead of:

if (self.initialSelections)

or only initialize the array in the initWithTitle method if
intialSelections is not nill:

if(initialSelections != nil)
{
self.initialSelections = [[NSArray alloc]
initWithArray:initialSelections];
}

Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#10 (comment)
.

from actionsheetpicker-3.0.

skywinder avatar skywinder commented on June 15, 2024

Hi.
It really is not so obvious what the correct behavior for this method.
And after your discussion I implement a batch of tests to cover most of all behaviours a4ec3ec & 2c5cb46.

What for this check?
I this, that check if (self.initialSelections && self.initialSelections.count > 0) need only if we want to ignore empty arrays. (like @[]).

Now the logic is: initialSelections.count must be equal to numberOfComponents in picker view.
But nil option is valid (set all components to 0 by default).

We already have initialiser without initialSelections
- (id)initWithTitle:delegate:showCancelButton:origin: and you can also set initalSections to nil.

So, I don't think that accept empty arrays is correct.

It's not clear, what behaviour is right.
I'm ready to discuss this.

from actionsheetpicker-3.0.

yannify avatar yannify commented on June 15, 2024

This works as expected, thanks for the quick fix!

I think this is the correct behavior, if you call showPickerWithTitle and do not pass initialSelections: i.e.

  • (id)showPickerWithTitle:(NSString *)title delegate:(id )delegate showCancelButton:(BOOL)showCancelButton origin:(id)origin
    {
    return [self showPickerWithTitle:title delegate:delegate showCancelButton:showCancelButton origin:origin
    initialSelections:nil ];
    }

then it should NOT instantiate an NSArray and assign it to self.initialSelections. i.e. the fix:

  • (id)initWithTitle:(NSString *)title delegate:(id )delegate showCancelButton:(BOOL)showCancelButton origin:(id)origin initialSelections:(NSArray *)initialSelections
    {
    ...
    if (initialSelections)
    self.initialSelections = [[NSArray alloc] initWithArray:initialSelections];
    ...
    }

Thanks!

from actionsheetpicker-3.0.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.