Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Unfortunately, no it didn't. The only things I changed from his code were the words 'picker' and 'row'. My picker was named already. Xcode prompted me to change 'row' so I changed it to the name of the variable that I use to indicate the number of the row.

I increase the value of the row variable by one each time a new entry is added to the list. It works fine for the UIPickerViews with only a single column/component.

What puzzles me is why everything works the first time and then after that only the first column/component will roll/animate.
 
Unfortunately, no it didn't. The only things I changed from his code were the words 'picker' and 'row'. My picker was named already. Xcode prompted me to change 'row' so I changed it to the name of the variable that I use to indicate the number of the row.

I increase the value of the row variable by one each time a new entry is added to the list. It works fine for the UIPickerViews with only a single column/component.

What puzzles me is why everything works the first time and then after that only the first column/component will roll/animate.

Any chance I could get you to just throw the whole thing on GitHub and link to it, so I can see it all in context?
It still sounds to me like it's an issue of threading; Which things happen in which order and operations interferring with each other during execution.
 
Any chance I could get you to just throw the whole thing on GitHub and link to it, so I can see it all in context?
It still sounds to me like it's an issue of threading; Which things happen in which order and operations interferring with each other during execution.


Sorry, I prefer not to do that. I will take some time to consider the problem, perhaps after a restful sleep the solution will present itself.

But if you can think of any other possible causes, then I would be glad to read about them!
 
Sorry, I prefer not to do that. I will take some time to consider the problem, perhaps after a restful sleep the solution will present itself.

But if you can think of any other possible causes, then I would be glad to read about them!


That's completely understandable

I don't really know what to do about your issue here-on out, but feel free to ask if anything else pops up; I might have the solution to that, even though I can't help further here. And hope you get it solved :)
 
Xcode has some debugging capabilities doesn't it? Is there something that I should look for using its' debugging capabilities to see what the UIPickerView is doing?
 
Xcode has some debugging capabilities doesn't it? Is there something that I should look for using its' debugging capabilities to see what the UIPickerView is doing?


You could set breakpoints at the animation, and see when values for the row count are updated relative to when the animation is set to begin, and if the animation tries to start before the row information has been updated.
 
I created another mini test project to test the code for UIPickerView animation. I found that when I have two components where the lists are populated fully and then use the code I posted earlier to animate both columns of the UIPickerView then it animates both columns/components fine.

I discovered too that when I create an array of empty values for which that array will be used to populate the second component/column of the UIPickerView in this way:

Code:
 var pickerArray = Array(repeating: "", count: 1)

then I append new values to the pickerArray and when the UIPickerView displays them that they will animate in the second component in the usual way that a UIPickerView animates.

Does this offer any hint to why my prior code doesn't work?

This way of fixing things seems haphazard.
 
Does this offer any hint to why my prior code doesn't work?

This way of fixing things seems haphazard.


Well, it makes me more sure about my original thought; There's a race condition between the animation call and the UIPicker figuring out how many elements are supposed to be in its list. It gets a call to animate, and then a call to change the rows, and thus cancelling the animation.

Why do you find the array approach haphazard?
 
Sorry, it simply seemed that way to me. I am not a computer science major so I don't understand as much about computer science and programming as yourself and phoneydeveloper. I will accept your explanation as it seems the most plausible now.

Well, all is fine now. Thanks to both you and phoneydeveloper for all of your help and suggestions!
 
Sorry, it simply seemed that way to me. I am not a computer science major so I don't understand as much about computer science and programming as yourself and phoneydeveloper. I will accept your explanation as it seems the most plausible now.

Well I am in no way really an expert yet either. I'm just finishing up my first year now (equivalent to second year in the US - different educational systems... It's complicated).
I'm currently writing an abstract machine for a semi-custom programming language as a part of my course on programming languages (finishing up this week). Seems like there's an issue in my compiler I need to fix, but I digress - Point I was getting to, is that I feel I have quite a good grasp of how things work fundamentally, but I don't yet have the best grasp of how UIKit in particular works, and Swift is not my main language. I understand general behaviour and language constructs, and I have used UIKit and Swift, but not as much as other technologies, and I'm not entirely acquainted with all the specifics of how the UIKit and App Delegate model really functions. In most of the code I've written, I've very much been in control, sending calls to libraries - but when you write code using a framework like UIKit, it's more of a two way dialogue. You don't just send calls to UIKit, it sends calls to you. To really follow the flow of things, you need to understand its behaviour as well as your own code, and I won't call myself so experienced with UIKit.

All that aside, I think it's great that you're digging into development. I started doing a fair bit myself before I started my CS education, and I'd like to just point out that there's a lot of corners of computing you'll never think of or stumble into if you just try and learn app development. That may not be an issue at all, but if you want to dig deeper I can highly recommend maybe following some online courses through iTunes U or something. Can be free. Algorithms and datastructures, languages, compilers, maybe databases if you want to interact with SQL at one point. Depending on how deep you dig, you might also want to take some mathematical courses like linear algebra.

For Swift specifically, the Swift Programming Language is a good ebook to read.

Of all of this though, I think algorithms and datastructures is the subject I'd most recommend looking into. Learning time complexity and space complexity of different algorithms, and how to store data to optimise for certain operations can be a great benefit down the road. Just don't get sad if red-black trees take a while to get the hang of... We all hate em ;).

I can also very strongly recommend LeetCode. You can use it with pretty much any programming language (including Swift). It's a set of a lot of smaller challenges, you write the code to solve it, submit it to the server, and it tells you if it's correct and how fast your code was compared to everyone else, and how much memory you used compared to others. It's great practice and a lot of fun.

Well, all is fine now. Thanks to both you and phoneydeveloper for all of your help and suggestions!

Sure. Let us/me know if you ever need anything else.
 
OP: Regarding the picker in this case it's being used in a way that was never intended. Its APIs don't properly support the kind of animations you're trying to do. That doesn't mean it's impossible, only that it may require some trial and error and more experience than you've got yet.

The code I showed with the animation block isn't guaranteed to work. It depends on how the picker animates its appearance. If you want to pursue that try to make the animation time longer. 1 second or longer would be good to try. Animation blocks do nest, which is what my code is intended to do, but I'm not sure what happens if a longer animation block is nested inside a shorter one. The other thing to do is to put print statements inside all of the picker callbacks. You can get a better idea of what the picker is doing this way. It's also possible that the animation API that's needed is a different one. There are others that target the view directly.
 
Well, things seem to have worked okay. I submitted the app so we'll see if they approve it.

I just want to say that my main interest in computer science and programming has been related to science - mostly bioinformatics though computer science as it applies to particle physics, celestial mechanics and dynamic astronomy, and climate modeling are all subjects that fascinate me.

I know that Perl, Python and C as well as R seem to be popular tools for bioinformatics and particle physics, but statistics seems to be extremely important in such fields and that's challenging for me.
 
Well, things seem to have worked okay. I submitted the app so we'll see if they approve it.

Out of curiosity, what's the app about?

I know that Perl, Python and C as well as R seem to be popular tools for bioinformatics and particle physics, but statistics seems to be extremely important in such fields and that's challenging for me.

I'm starting my statistics course next semester, where we'll write a lot of R.
Python is just a fairly accessible scripting language in general, and doesn't require statistical knowledge more than any other programming language might.
C is not very accessible and is quite close to machine code. - Swift is considered a C derivative language, in the same camp as Objective-C, Java, and many many more. C isn't so nice to work with compared to the other mentioned, but can result in faster code if you know how to work it. - Also not necessarily very statistical.

I don't really know Perl, so can't really justly speak about it
 
  • Like
Reactions: MisterSavage
It's an app to help you learn the sequence of the geology of the eras by memorizing the names in the proper orders for the Ages, Epochs, Periods, Era, Eons, SuperEons, etc.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.