2012-02-27 3 views
1

ITunesPlaylist 개체의 배열로 NSPopUpButton을 채우려고합니다. 나는MacRuby에서 NSPopUpButton을 ITunesPlaylist 개체와 바인딩하려면 어떻게해야합니까?

app = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") 
playlists = app.sources.objectWithName("Library").userPlaylists 

myArrayController.setContent playlists 

모든 재생 목록이 NSPopUpButton에 나타납니다 NSPopUpButton에 NSArrayController 바인딩을 가지고 있지만 그들은 모두 내가하고 싶은 것은의 내용 값 ITunesPlaylist.name 결박이다

<ITunesUserPlaylist:0x4018a5000: iTunesUserPlaylist 0 of iTunes Source "Library" of Application "iTunes" (51822)> 

와 이름이 NSPopUpButton,하지만 그것을 작동시킬 수 없습니다.

Scripting Bridge API 호출 (예 : ITunesPlaylist, ITunesTrack)에서 반환하는 개체의 클래스 정의에 대한 문서는 거의없는 것처럼 보입니다.

누군가가 내게 몇 가지 포인터를 줄 수 있습니까? 궁극적으로 사용자의 iTunes 재생 목록을 계층 적 형태로 보여주는 드롭 다운 메뉴를 만들고 싶습니다.

답변

1

올바른 키 경로로 바인딩을 올바르게 설정 했습니까? bridgesupport 파일을로드 했습니까? ITunesUserPlaylist 클래스를 확인했으며 KVC를 준수해야합니다.

playlists.first.valueForKey('name') 

올바른 이름을 반환합니다.

더 많은 코드를 공유하는 경우 잠재적으로 문제를 조사 할 수 있습니다.

또한, 여기에 몇 가지 방법은 재생 목록에서 사용할 수 있습니다 : 당신의 도움에 대한

Class: iTunesPlaylist 
Properties: 
duration (the total length of all songs (in seconds)) 
name (the name of the playlist) 
parent (folder which contains this playlist (if any)) 
shuffle (play the songs in this playlist in random order?) 
size (the total size of all songs (in bytes)) 
songRepeat (playback repeat mode) 
specialKind (special playlist kind) 
time (the length of all songs in MM:SS format) 
visible (is this playlist visible in the Source list?) 

Method: tracks 
Returned: SBElementArray 
---- 
Method: moveTo:(SBObject *)to 
Returned: void 
Move playlist(s) to a new location 
---- 
Method: searchFor:(NSString *)for_ only:(iTunesESrA)only 
Returned: iTunesTrack 
search a playlist for tracks matching the search string. Identical to entering search text in the Search field in iTunes. 

Class: iTunesUserPlaylist 
Properties: 
shared (is this playlist shared?) 
smart (is this a Smart Playlist?) 

Method: fileTracks 
Returned: SBElementArray 
---- 
Method: URLTracks 
Returned: SBElementArray 
---- 
Method: sharedTracks 
Returned: SBElementArray 
---- 
+0

도움 주셔서 감사합니다. 내 문제는 다음과 같습니다. – goofrider

0

감사합니다. 내가 처음 프로젝트에 "iTunes.h"를 가져하지 않는 한 4 인터페이스 빌더는 ArrayController의 클래스 이름 필드에 유형 "iTunesPlaylist"를 인식하지 못하는

  1. 엑스 코드, I가 있었다 : 그것은 내 문제가이 있었다 밝혀졌다 그것을 생성하십시오 :

    $ sdef /Applications/iTunes.app | SDP -fh --basename 아이튠즈

  2. 팝업 버튼 다음 엑스 코드 IBuilder에 바인딩 NSPopUpButton의 내용에 "모달 키 경로"에서 "이름"을 설정하여 ArrayController의 arrangedObjects의 "이름"에 바인더 제본 할 수있다, 그러나 "Application Keys가 아니라면 Raise"가 기본적으로 선택되었으므로 ArrayController가 비어있어 시작시 응용 프로그램이 중단됩니다. 선택을 취소하고 모든 것이 잘 작동합니다.

+1

헤더 파일 및 문서에 대한 자세한 내용은 http://mybist.com/2010/01/17/controlling-itunes-with- macruby/ –

+0

실제로 귀하의 게시물은 iTunes.h 요구 사항에 대해 설명했던 곳 중 하나였습니다. 그레이트 포스트 !! – goofrider