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

configurePickerView for ActionSheetCustomPicker throws exception #10

Closed
yannify opened this issue Jul 19, 2014 · 4 comments
Closed

configurePickerView for ActionSheetCustomPicker throws exception #10

yannify opened this issue Jul 19, 2014 · 4 comments

Comments

@yannify
Copy link

yannify commented Jul 19, 2014

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];
    }
@DoctorG
Copy link

DoctorG commented Jul 19, 2014

It's the same thing

Sent from my iPhone 5s

On Jul 19, 2014, at 1:49 PM, Yanni Mitis notifications@github.com 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.

@yannify
Copy link
Author

yannify commented Jul 19, 2014

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 <
notifications@github.com> wrote:

It's the same thing

Sent from my iPhone 5s

On Jul 19, 2014, at 1:49 PM, Yanni Mitis notifications@github.com
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)
.

@skywinder
Copy link
Owner

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.

@yannify
Copy link
Author

yannify commented Jul 20, 2014

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!

@yannify yannify closed this as completed Jul 20, 2014
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

3 participants