PickerVew によるメニュー選択 (3/3)解決篇2012年11月12日 18:07

解決策はロジックを飛び越えて訪れるものらしい・・・?
もう面倒になって、タイマーのあら捜しをあきらめかけていた。そんな時ふとスレッドのことが気になりだした。UIPickerView も名前どうり UIだからメインスレッドで表示しているからである。そこに横槍を入れるならサブスレッドしかないだろう。早速やってみた。
最初 (1)不思議篇 で示したピッカーの停止した時に呼ばれるデリゲードメソッドの次の行に移動させる部分 (太字) だけをサブスレッドで実行するのだ。

.....
.....
if (nowIndex_ == 0) {
    // 次の行に移動させる
    nowIndex_++;
    [picker_ selectRow:nowIndex_ inComponent:component
        animated:YES];
}

これで決まり!
きちんと書くとこんな感じ・・・

// 停止時のデリゲート
- (void) pickerView:(UIPickerView*)pickerView didSelectRow:(NSInteger)row
 inComponent:(NSInteger)component
{
    // 位置をキープするインスタンス変数
    nowIndex_ = row;
    // ドラムの表示 0の位置を index=0 と想定
    if (nowIndex_ == 0) {
        // 次の行に移動させる
        nowIndex_++;
        [self adjustPickerPosition:nowIndex_]; // 移動メソッドを呼ぶ
    }
}

// ドラムの移動メソッド
- (void)adjustPickerPosition:(NSInteger)row 
{
    NSLog(@"adjusted!");
    // サブスレッド
    NSOperationQueue *queue = [[[NSOperationQueue alloc]init] autorelease];
    [queue addOperationWithBlock:^{
        // 行の表示位置をデーターに合わせる
        [picker_ selectRow:row inComponent:0 animated:YES];
    }];
}
NSOperationQueueクラスを使用しているが、iOS 4以降は内部でGCDを使用しているため結果的には同じである (参照:「詳解 iOS 5プログラミング」) 。これでやっと決定打となった。

簡単に検証してみる
さて、せっかくだから逆方向に検証してみよう。手順は、この NSOperationQueueクラスの mainQueueメソッドで取得したキューを使って、このサブスレッドの中からメインのスレッドで実行してみたらどうなるか? これで最初の時と同じように上手く行かなくなれば理屈は成り立つ。
    .....
    .....
    // サブスレッド
    NSOperationQueue *queue = [[[NSOperationQueue alloc]init] autorelease];
    [queue addOperationWithBlock:^{
        // メインスレッドで実行
        NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
        [mainQueue addOperationWithBlock:^{
            // 行の表示位置をデーターに合わせる
            [picker_ selectRow:row inComponent:0 animated:YES];
        }];
    }];
    .....
さて、これは予想どうりに失敗する。これでメインスレッド同士の競合が原因であることの検証もできたが、ここから先の解析は力不足であるし追求しないことにする。

(おわり)

コメント

_ The Heel Lift ― 2016年09月10日 13:07

Hi there, just became alert to your blog through Google, and
found that it is really informative. I am gonna watch out for brussels.

I will appreciate if you continue this in future.

Numerous people will be benefited from your writing. Cheers!

_ HeelLifts ― 2016年09月14日 09:31

Lovely just what I was looking for. Thanks to the author for taking his
time on this one.

_ Heel and Shoe Lifts ― 2016年09月14日 10:36

Very interesting details you have noted, thank you for putting up.

_ inner soles for shoes ― 2016年09月17日 18:09

Appreсiɑte this post. Let me try it out.

_ Ball of Foot Pain ― 2017年03月01日 08:02

Valuable info. Lucky me I discovered your site accidentally, and I am shocked why this twist of fate did not took
place in advance! I bookmarked it.

_ workout shoes ― 2017年03月02日 16:33

If some one needs to be updated with latest technologies after that he must be go to see this web page and be up to date
daily.

_ illinois cash advance loan ― 2017年03月05日 05:47

Spot on with this write-up, I seriously believe this site needs far more
attention. I?ll probably be back again to see more, thanks for the information!

_ manicure ― 2017年03月20日 00:15

Useful info. Fortunate me I discovered your web site unintentionally, and I'm stunned why this accident didn't happened earlier!
I bookmarked it.

_ uniquetees.us ― 2017年03月20日 15:42

It' not on the list, but 1 of my preferred sites is - you can design and style any kind of t-shirt you like if that is
your factor. it's a lot of entertaining!

_ Fletcher ― 2017年03月20日 16:09

When you go to the show room, you'll be able to choose from about two dozen car manufactures and choose one in every of their cars.

_ Custom Silicone Wristbands in USA ― 2017年03月20日 16:21

I've been browsing online more than three hours today, yet I never
found any interesting article like yours. It's pretty worth enough for me.

Personally, if all web owners and bloggers made good content as you did, the net will be a lot more useful than ever before.|
I couldn't resist commenting. Perfectly written!|
I will immediately grab your rss as I can not find your email subscription link or e-newsletter service.
Do you've any? Pleaae allow me recognhise so that I mayy subscribe.
Thanks.|
It's approprate time to make soke plans for the future and it is
time to be happy. I have read this post and if I could I wish to suggest you
few interesting things or suggestions. Mayhbe yoou could
wfite nwxt articles referring to this article. I desire to read
more things about it!|
It is appropriate time to make some plans for the future and
it's time to bbe happy. I have learn this submit and if
I could I want too recommend you some interesting things or advice.
Perhaps you ccan write next articles referring to this article.
I want to learn more things approximately it!|
I have bbeen surfing on-line moore than 3 hours lately, but I by
no mrans found any fascinating article like yours. It's beautiful value nough for me.
Personally, if all webmasters and bloggers made excellent content material as yoou did, the internet will likely be a lot more helpful
than ever before.|
Ahaa, its pleasant discussion on the topic of thi puece of writing at this place at
this website, I have read all that, soo now me also commenting at thhis place.|
I am sure this article has touched all the internet users,
its really really good piece of writing on building up neww web site.|
Wow, this paragraph is good, my sisdter is analyzing these kinds of things,
therefore I am going too tell her.|
bookmarked!!, I like your site!|
Way cool! Some extremely vqlid points! I appreciate you penning
this write-up plus the rest of the website is also really good.|
Hi, I do think this is a great blog. I stumbledupon it ;
) I am going to return once again since I book marked it.
Money and freerdom is the best wway too change, mmay you be rich and contknue to help othyer people.|
Woah! I'm really enjoying the template/theme of this site.
It's simple, yet effective. A lot of imes it's hard to get that "perfect balance" between usability and appearance.
I must say you've done a amazing job with this.
Also, the blog loads extremely fast for me on Firefox.
Exceptional Blog!|
These are genuinely wonderful ideas iin concerning blogging.
You have touched some nice points here.
Any way keep up wrinting.|
I love what you guys are usually up too. This type of clever work and
reporting! Keep up the awesome works guys I've incorporated you guys to blogroll.|
Hey there! Someone in my Myspace group shared this website
wiyh us so I came to check it out. I'm definitely loving tthe information. I'm bookmarking
and will be tweeting this to my followers! Wonderful
blog and fantastic style and design.|
I like what you gys are usually up too. This type of clever work
and coverage! Keep up the ssuperb works guys I've incorporated you guys tto mmy personal blogroll.|
Howdy would you mind sharing which blog platform you're working with?
I'm planning to start my own blog soon buut I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
Thee reason I ask is because your design seems different then most blogs and I'm looking
for something unique. P.S Apologies for being off-topic buut I had to ask!|
Howdy would you mind lstting me kknow which webhost you're working with?
I've loaaded your blog iin 3 completely diffeerent browsers and I must say this blog loads a lot quicker
then most. Can you recommend a good web hosting provider at a reasonable price?

Many thanks, I appreciate it!|
I like it when individuals come togethewr and share ideas.
Great site, stick with it!|
Thank yyou for the good writeup. It in fact was a amusement account it.

Lookk advahced to more added agreeable from you!
By the way, how can we communicate?|
Hello just wanted to give you a quick heads up.

Thhe text in your article seem to be running off the screen in Opera.
I'm not sure if this is a fofmatting issue oor something to do with internet browser compatibility but I figured I'd post to let you
know. The style and design look great though! Hope you gett the issue solved soon.
Thanks|
This iss a topic whicch is close to my heart... Take care!
Where are your contact details though?|
It's very simple to find out anny topic on web as compared too books, as
I found tthis post aat this web site.|
Doess your website have a contact page? I'm having trouble locating it but,
I'd lile to syoot you an email. I've got some recommendations for
your blog you might be interested in hearing.
Either way, great blog and I look forward to seeing it
improve over time.|
Hello! I've bbeen reading your web site foor some time
now and finally got the courage to go ahead and
give youu a shout ouut from Kingwood Tx!
Just wanted to tell you eep up the excellent work!|
Greetingss from Carolina! I'm bored too death at work so I decided to check out your website
on mmy iphone during lunch break. I lovee the info
you present here and can't wait to take a look when I get
home. I'm shocked att how quick your blog loaded on my phone ..

I'm not even using WIFI, just 3G .. Anyhow,
fantastic site!|
Its like youu learn my thoughts! You seem to know so muchh approximately this, such as you wrote the e-book inn it or something.

I think that you just can do with a few
percent to power the message home a little bit, but other than that, this is antastic blog.
An excellent read. I'll deffinitely be back.|
I visited vawrious web pahes except the audio feature for audio songs current at this website is truly marvelous.|
Hi there, i read your blog from time to time and i own a similar one and i wwas just wondering if you get a lot of spam comments?
If so how do you reduce it, any plugin or anything you can suggest?I get so
much latyely it's driving me insane soo any assistance is
very much appreciated.|
Greetings! Very helpful advice within this post! It is the
little changes which will make the most important changes.
Thanks for sharing!|
I really love youur website.. Excellent colors & theme.
Did you create this web site yourself? Please reply back as I'm trying to
create my very owwn website and would loge to knpw where you got thiss ftom or exactly what
the theme is called. Many thanks!|
Hi there! This post could not be written much better!
Going through this article reminds me of my previous roommate!
He always kept talking about this. I am going to forward this article to him.

Fairly certain he will have a great read. Thanks for sharing!|
Whoa! This blog looks exactly like my old one! It's on a entirey different subject
but it has pretty much the same layout and design. Excellent choice off colors!|
There's definately a lot to know about this subject. I love all the points yyou have made.|
You've made some really good points there. I checked on the web to learn more about the issue and found most individuals
will ggo along with your views on this website.|
Hi there, I check your blogs daily. Your humoristic style is witty, keep doing
what you'redoing!|
I simply could nnot depart your site prior to suggesting
that I really loved the usual info an individual supply foor your guests?
Is gonna be back ceaselessly in order to inspect neew posts|
I want tto to thank you ffor this wonderful read!!
I certainly enjoyed every little bit off it. I have you bookmarked to llook at new
stuff you post…|
What's up, just wanted to mention, I loved this blog post.
It was practical. Keep on posting!|
Hello,I enjoy reading through your article post.
I wanted to write a little omment to support you.|
I always spent my half an hour to read thiss blog's posts every day along with a cup of
coffee.|
I every time emailed this weblog post page to all my associates, because if like to read it after
that my friends ill too.|
My developer is trying to cobvince me to move to .net from PHP.
I have always disliked the idea because of
the expenses. Buut he's tryiong none the less. I've been using Movable-type on numerous websites for about a year and am
conccerned about switching too another platform.
I have heard excellsnt things about blogengine.net.
Is there a way I can transfer all my wordpress contednt into it?
Any help would be greatly appreciated!|
Hello! I could have sworn I've beeen to this wedbsite before
but after going through a few of the articles I realized it's
new to me. Anyhow, I'm certainly happy I found it aand
I'll be book-marking it and checking bck often!|
Wonderful article! This is thhe type of info that are suposed tto be shared
around the internet. Disgrace on Google for not positioning this
publish higher! Come on over and visit my site . Thanks
=)|
Heya i'm for the first time here. I came across this board aand I ffind It truly useful
& it helped me out much. Ihop to give something
back aand help others likke youu aided me.|
Hi there, I believe your blog might be having browser compatibility issues.
Whenever I tke a look at your webb site in Safari, it looks fine however, if
opening in Internet Explorer, it has some overlapping issues.
I merely wanted too providee you with a quick heads up!
Apart frfom that, great blog!|
Someone necessarily lend a hand too make significantly articles I'd state.

That is the first time I frequented your website page and up to now?
I amazed with the rsearch you made to makie this particular submit
amazing. Fantastic task!|
Heya i'm for the primary time here. I fouind this board and
I find It really ussful & it helped me out a lot. I hope too give something again and aid others lie you aided me.|
Hey there! I just want to gve you a big thumbs up for your excellent info you have hewre on this post.
I am coming back to your website for more soon.|
I always used to study article in news papers but now as I am
a user off web so from now I am using net foor articles, thanks to
web.|
Your means of telling all iin this post is in fact fastidious, every one be capable off without difficulty know
it, Thanks a lot.|
Hi there, I found youjr blog byy means of Google while searching for a related matter, your site
got here up, it seems to be good. I've bookmarked it in my google
bookmarks.
Hi there, jusat was alert to your webllog via Google, and
found that it's truly informative. I am ging to watch out for brussels.
I will appreciate for those who proceed this in future.

Numerous folks shall be benefited from your writing.
Cheers!|
I am curious too find out what blog platform you happen tto bee utilizing?
I'm experiencing some minor security problems with my latest blog and I would like to
fund something more safeguarded. Do you have any suggestions?|
I'm really impressed with your writing skills and also wjth
the layout on your blog. Is this a paid theme or did you modifyy it yourself?
Anyway keep uup the nice quality writing, it is rare to see a nice blog like this one today.|
I'm extremely impressd with your writing abilities and also
with the format on your weblog. Is this a paid topic
or did you modify it yourself? Either way keep up the excellent quality writing, it's uncommon to look a nice weblogg like this one
nowadays..|
Hello, Neat post. There's a problem with your site in interneet explorer, might test this?
IE nonetheless iis the market chief and a good poretion of people will miss your wonderful writing due to this problem.|
I am not sure whdre you are gedtting your information, but
great topic. I needs to spend some time learning
mlre or uderstanding more. Thanks for excellent information I wass looking for this information foor my mission.|
Hello, i think that i saw you visifed my site so i came to “return the favor”.I am trying to find things to improve
myy web site!I suppose itss okk to use a few of your \

_ tshirt for your age ― 2017年03月20日 16:24

The major disadvantage of direct-to-garment printing is
the lack of volume discount for huge orders, as it takes the same quantity of time to print each and every shirt.

_ create wristbands ― 2017年03月20日 19:04

I truly love your site.. Pleasant colors & theme.
Diid yyou create this web site yourself? Please reply back as I'm
attempting to create my oown website and would lofe to
find out where you got this from or what the theme is named.
Thank you!

_ manicure ― 2017年03月30日 20:06

Hi there mates, how is all, and what you desire to say about this article,
in my view its really awesome designed for me.

_ manicure ― 2017年03月30日 20:19

Asking questions are truly pleasant thing if you are not understanding something entirely, however this
post offers good understanding yet.

_ manicure ― 2017年03月30日 20:32

Every weekend i used to pay a visit this web site, because i want
enjoyment, for the reason that this this website conations actually pleasant funny stuff
too.

_ manicure ― 2017年03月30日 20:47

I could not refrain from commenting. Exceptionally well
written!

_ manicure ― 2017年03月30日 20:58

Why visitors still make use of to read news papers when in this technological world the whole thing is
existing on net?

_ manicure ― 2017年03月30日 21:08

I'm amazed, I must say. Seldom do I encounter a blog that's both equally educative and entertaining,
and let me tell you, you've hit the nail on the head. The issue is an issue that too few men and women are speaking
intelligently about. I am very happy I stumbled across this
in my hunt for something concerning this.

_ manicure ― 2017年03月30日 21:16

This website was... how do you say it? Relevant!! Finally I've found something that helped me.
Thank you!

_ manicure ― 2017年03月30日 21:31

Fabulous, what a website it is! This weblog provides valuable data to
us, keep it up.

_ manicure ― 2017年03月30日 21:33

What's up every one, here every one is sharing these familiarity, therefore it's fastidious
to read this blog, and I used to go to see this webpage every
day.

_ manicure ― 2017年03月30日 21:37

Pretty! This was an extremely wonderful post.
Many thanks for providing this information.

_ manicure ― 2017年03月30日 21:38

Hello! I know this is kind of off topic but I was wondering if you knew where I could locate
a captcha plugin for my comment form? I'm using the same blog platform as
yours and I'm having difficulty finding one? Thanks a lot!

_ manicure ― 2017年03月30日 21:39

Normally I do not read article on blogs, however I wish to say that this write-up very
compelled me to check out and do it! Your writing taste has been amazed me.
Thanks, quite great post.

_ manicure ― 2017年03月30日 21:53

Aw, this was an incredibly nice post. Taking a few minutes and actual
effort to produce a great article… but what can I say… I put
things off a lot and don't manage to get nearly anything done.

_ manicure ― 2017年03月30日 22:04

Excellent post. I used to be checking constantly this blog and I am inspired!
Extremely helpful info specifically the ultimate part :) I deal with such information much.
I was seeking this particular information for a very long time.
Thank you and good luck.

_ manicure ― 2017年03月30日 22:15

Incredible! This blog looks exactly like my old one!

It's on a totally different topic but it has pretty much the same layout and design. Great choice of colors!

_ manicure ― 2017年04月10日 20:47

Good day! Do you use Twitter? I'd like to follow you if that would be okay.
I'm undoubtedly enjoying your blog and look forward to
new posts.

_ BHW ― 2017年04月12日 20:18

Hey would you mind stating which blog platform you're
working with? I'm planning to start my own blog
in the near future but I'm having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.

The reason I ask is because your design seems different then most
blogs and I'm looking for something unique.
P.S My apologies for being off-topic but
I had to ask!

_ BHW ― 2017年04月16日 06:42

Wonderful goods from you, man. I've understand your stuff previous to and you're
just too excellent. I actually like what you've acquired here, certainly
like what you are stating and the way in which you say
it. You make it entertaining and you still care for to keep it smart.

I cant wait to read much more from you. This is really a tremendous
website.

_ manicure ― 2017年04月28日 02:48

Incredible points. Sound arguments. Keep up the amazing spirit.

_ http://nanacarratura.weebly.com/blog/causes-hammertoe-deformity ― 2017年05月02日 08:59

Because the admin of this site is working, no doubt very quickly it will be renowned, due to its quality contents.

_ http://nanacarratura.weebly.com/blog/causes-hammertoe-deformity ― 2017年05月02日 09:00

Because the admin of this site is working, no doubt very quickly it will be renowned, due to its quality contents.

_ http://meridithalmario.blogas.lt ― 2017年05月02日 10:14

Loving the information on this website, you have done great job on the blog posts.

_ order custom patches ― 2017年05月03日 20:41

Our latest addition to the limousine fleet is the
7 passenger Cadillac Escalade. The turbo 4-banger in the Volkswagon GTI Mk5 is fairly unique among such engines in that it produces huge amounts of torque at
a relatively low number of RPMs. It is available in two versions of petrol and diesel and has been a very reasonable
price.

_ http://www.website-laten-maken.blogspot.be/2017/04/webdesigner-antwerpen.html ― 2017年05月03日 20:42

Hi to all, how is everything, I think every one
iss getting more from this website, and your views are fastidious in favor of new viewers.

_ window cleaning vancouver ― 2017年05月03日 20:44

The warranties for some branded cars may go up to 3 or 4 years depending on the model.
Driven aggressively, the cars will run out of power in about
30 minutes. You can visit Monaco Motors for your classic car's regular check-up and
you can also do your own daily car care so your
vintage car will look as new and luxurious as ever.

_ drywall contractors ― 2017年05月03日 20:47

Our latest addition to the limousine fleet is the 7 passenger
Cadillac Escalade. All since then, Indica is floating in the market with a regular sale.
The damage varies from vehicle to vehicle but can be as
small as light hail damage which is barely visible through to damage caused by falling trees.

_ Power washing Vancouver ― 2017年05月03日 20:49

The remote control includes 3 different frequencies,
and you can operate the car from up to 8 meters. Strict standards and excellence in service is what made
Cullitons the premiere limo service of choice
for thousands of Torontonians as well as visiting guests from all over the world.
The damage varies from vehicle to vehicle but can be as small as light hail damage which is barely
visible through to damage caused by falling trees.

_ roof repairs Vancouver ― 2017年05月03日 20:56

Our latest addition to the limousine fleet is the 7 passenger Cadillac
Escalade. Today, Parents magazine and car-buying platform
Edmunds. It includes 4 different frequencies so you can race against your friends.

_ discuss ― 2017年05月03日 20:57

Hello There. I found your blog using msn. This is an extremely
well written article. I'll make sure to bookmark it and come back to read more
of your useful information. Thanks for the post. I will definitely
comeback.

_ how to get psn gift cards free ― 2017年05月03日 21:04

As more customers obtain e-present playing cards, the awareness of this type
of present is growing.

_ myukdeals.blogspot.co.uk ― 2017年05月03日 21:05

Hello there! Do you know if they make any plugins to help with SEO?
I'm trying to get my blog to rank for some targeted keywords but I'm
not seeing very good gains. If you know of any please share.
Many thanks!

_ Bathroom reno Vancouver ― 2017年05月03日 21:06

Abroad, modified cars long, first appeared in the modified car to better participate in the
competition, drag racing, like so many people have converted their car engines,.
Producing a very light car will drop its fuel consumption, and oil companies will not appreciate this.
Access Free Online Maps via Wi - Fi or 3G network, such as Google Map.

_ manicure ― 2017年05月04日 00:58

I really like reading a post that will make people think.
Also, thank you for permitting me to comment!

_ www.liftenvoorringland.be ― 2017年05月13日 01:33

It's acctually very difficult inn this active life to listen news on TV,
therefore I just use the web for that reason, and get the most up-to-date information.

_ Debora ― 2017年05月13日 02:45

Thank you, I have just been searching for information approximately this subject for a while and yours iss the greatest I've
found out so far. However, what in regards to the conclusion? Are you sure about the source?

_ Http://Website-Laten-Maken.Blogspot.Be ― 2017年05月13日 05:07

You ought to be a part oof a contdst for one of
the most useful sites online. I'm going to highly recommend this site!

_ http://website-laten-maken.blogspot.be ― 2017年05月13日 07:55

Hello, after reading tthis rdmarkable article i am as wesll happy to share
my know-how here with mates.

※コメントの受付件数を超えているため、この記事にコメントすることができません。

トラックバック