Script Bridge 和 iPhoto - 纬度/经度信息仅是 NSInteger?

发布于 2024-12-03 20:27:10 字数 689 浏览 1 评论 0原文

我正在尝试使用 Obj-C 中的 Script Bridge(XCode 4.1,SDK 10.7)访问 iPhoto 图像中的 GPS 信息。下面是一个代码片段:

 iPhotoApplication *iPhoto = [SBApplication applicationWithBundleIdentifier:@"com.apple.iPhoto"];
  NSArray *selection = [iPhoto selection];
  for ( iPhotoPhoto *i in selection ) { 
    NSLog(@"'%@': lat %ld, lon %ld", [i imageFilename], [i latitude], [i longitude]);   
  }

不幸的是,纬度和经度属性是 NSInteger 类型,它产生的结果非常不精确(例如 38,120),以至于完全无用。使用Applescript 访问相同的属性时会产生正确的值(例如,38.03555555、-120.401388883333)。有没有更好的方法在 Obj-C 中获取此信息?

另外,iPhotoPhoto 类有一个名为“id”的属性,由于 id 是 Obj-C 保留字,所以无法获取该属性。 [i id] 编译但崩溃。再说一遍,我如何获得这个属性?

我尝试为 XCode 4/SDK 10.7 构建 appscript 但没有成功。

I am trying to access the GPS info in iPhoto images using Script Bridge in Obj-C (XCode 4.1, SDK 10.7). Here is a code snippet:

 iPhotoApplication *iPhoto = [SBApplication applicationWithBundleIdentifier:@"com.apple.iPhoto"];
  NSArray *selection = [iPhoto selection];
  for ( iPhotoPhoto *i in selection ) { 
    NSLog(@"'%@': lat %ld, lon %ld", [i imageFilename], [i latitude], [i longitude]);   
  }

Unfortunately, the latitude and longitude properties are type NSInteger, which yields results so imprecise (eg, 38,120) as to be totally useless. The same properties when accessed with Applescript yield correct values (eg, 38.03555555,-120.401388883333). Is there a better way to get this info in Obj-C?

Also, the iPhotoPhoto class has a property called "id", which is impossible to get since id is an Obj-C reserved word. [i id] compiles but crashes. Again, how do I get this property?

I have tried to build appscript for XCode 4/SDK 10.7 but without success.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠我空喜 2024-12-10 20:27:10

这可以通过获取其属性来实现

NSDictionary *dict;
for ( iPhotoPhoto *i in selection ) {
      dict = [i properties];
      NSLog(@"'%@': lat %@, lon %@, ID %@", [i imageFilename], [dict objectForKey:@"latitude"], [dict objectForKey:@"longitude"], [dict objectForKey:@"id"]);
}

This is possible by getting its properties

NSDictionary *dict;
for ( iPhotoPhoto *i in selection ) {
      dict = [i properties];
      NSLog(@"'%@': lat %@, lon %@, ID %@", [i imageFilename], [dict objectForKey:@"latitude"], [dict objectForKey:@"longitude"], [dict objectForKey:@"id"]);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文