我正在尝试编写一个快速控制iTunes的应用程序.但是在初始化应用程序时返回一个类型的对象AnyObject,但必须是iTunesApplication.
此对象不响应iTunes的方法和变量.谁知道如何使它工作?
var iTunes = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes")
Run Code Online (Sandbox Code Playgroud)
iTunes.h标题还包含我需要访问但不能访问的类.这些类会导致编译错误,就好像它们不在声明的iTunes.h中一样.
为什么这件事发生在我身上尚不清楚.
通过@class声明为iTunes.h的类的完整列表:
@class iTunesPrintSettings,iTunesApplication,iTunesItem,iTunesAirPlayDevice,iTunesArtwork,iTunesEncoder,iTunesEQPreset,iTunesPlaylist,iTunesAudioCDPlaylist,iTunesLibraryPlaylist,iTunesRadioTunerPlaylist,iTunesSource,iTunesTrack,iTunesAudioCDTrack,iTunesFileTrack,iTunesSharedTrack,iTunesURLTrack,iTunesUserPlaylist,iTunesFolderPlaylist,iTunesVisual,iTunesWindow,iTunesBrowserWindow,iTunesEQWindow,iTunesPlaylistWindow;
例如,在Objective -c中,您可以使用类似的东西来获取当前曲目
iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
NSLog(@"Current song is %@", [[iTunes currentTrack] name]);
Run Code Online (Sandbox Code Playgroud)
但我无法迅速获得相同的工作.
下面的Applescript是我用过多年的形式.并且基本上是使用Applescript发送电子邮件的众所周知的方法.
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"IP Address", content:"Your IP Address Is: 86.195.132.134"}
tell newMessage
set visible to false
set sender to "mark@sender.com"
make new to recipient at end of to recipients with properties {address:"recipient@mac.com"}
send
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
我今天刚刚注意到的是脚本中设置的"发件人"电子邮件,如果未选中其帐户邮箱,则可能不是Mail.app使用的电子邮件.如果选择了主收件箱,或者如果选择了单个邮箱,则将使用随机邮箱,然后将使用其帐户中的地址.
我认为这是因为在Mail首选项中,在Composing下.有一个设置为" 发送新邮件:"

你不能选择'否'.唯一的选项是"所选邮箱的帐户"或组合框下拉列表中的一个电子邮件地址.
我必须承认,在我去狮子会之前,我不知道这是否发生过.
有没有人知道这个的修复,或者这是一个已知的错误?
谢谢.
我想在我的iOS v5通用应用程序中切换statusBar.
但发现其他人有UIViews(在我的情况下,subViews添加到主视图)只回收隐藏statusBar剩下的20px,如果你然后旋转设备(我使用模拟器)
我的观点是以编程方式完成的.
我尝试了通过谷歌搜索找到的一些建议,但似乎没有任何工作.即更改autoresizing/mask,wantsFullScreenLayout,setNeedsLayout,在IB'使用全屏.
我终于意识到我将视图框架高度设置 为0,它的高度是[[UIScreen mainScreen] applicationFrame] size.height的高度.
我想出的是:将视图框架高度设置 为-20,并将其高度限制为[[UIScreen mainScreen] applicationFrame] size.height + 20
在viewDidLoad中.
CGRect theDeviceRect= [[UIScreen mainScreen] applicationFrame];
newMap.frame = CGRectMake(0, -20, theDeviceRect.size.width, theDeviceRect.size.height+20);
Run Code Online (Sandbox Code Playgroud)
我也在willAnimateRotationToInterfaceOrientation: delegate中有这个.
现在当我切换状态栏时:
- (void) toggleStatusBarAction:(id)sender{
BOOL istathidden= [[UIApplication sharedApplication] isStatusBarHidden];
[[UIApplication sharedApplication] setStatusBarHidden:!istathidden withAnimation:UIStatusBarAnimationFade];
}
Run Code Online (Sandbox Code Playgroud)
一切都按预期工作.但是我想看看我的解决方案是好坏的方式,如果我遗失了什么?:
提前谢谢了.MH
我正在制作游戏,我想获取启动器的有效全屏分辨率列表。我找不到为 Mac OS X 执行此操作的任何方法;
就像在系统首选项 Displays窗格中一样。

是否可以?
我有一个简短而甜蜜的程序,用AppleScript输出我的内部和外部ip.
这是Applescript代码:
set inIP to IPv4 address of (get system info)
set exIP to (do shell script "curl ipecho.net/plain")
display dialog "Internal: " & inIP & "
External: " & exIP
Run Code Online (Sandbox Code Playgroud)
我希望它能在后台不断更新,最好不要像现在那样在显示对话框功能中更新.
我不希望显示对话框不断弹出,所以我正在查找示例,在菜单栏中显示IP .
我不知道这是否可以与Applescript一起使用
applescript ×2
objective-c ×2
c++ ×1
desktop ×1
dialog ×1
ios ×1
ip ×1
itunes ×1
macos ×1
menubar ×1
resolutions ×1
swift ×1
uiview ×1
xcode ×1