我正在尝试编写一些自动化代码(主要在Ruby Selenium中).在某些时候,在Safari中打开文件选择器,以便用户可以选择要上载的文件.Selenium无法处理这个,但我认为AppleScript应该能够.我是AppleScript的新手,并且无法找到任何自动执行文件选择器对话框的样板代码.我正在阅读AppleScript文档,但任何想法都会有所帮助.
我有一个FourByFourBoard扩展的类GameBoard。我定义了以下字段:
private Map<Integer,List<Key<? extends GameBoard>>> mGameTypeToKeysMap = new Hashtable<Integer,List<Key<? extends GameBoard>>>();
private List<Key<FourByFourBoard>> mFourByFourBoardKeys = new ArrayList<Key<FourByFourBoard>>();
Run Code Online (Sandbox Code Playgroud)
在我的构造函数中,我尝试调用:
mGameTypeToKeysMap.put(Game.FOUR_BY_FOUR, mFourByFourBoardKeys);
Run Code Online (Sandbox Code Playgroud)
但我明白了:
put(Integer, List<Key<? extends GameBoard>>)类型中的 方法Map<Integer,List<Key<? extends GameBoard>>>不适用于参数(int, List<Key<FourByFourBoard>>)
我可以使用不同的方法来完成我想做的事情,但是在盯着代码一段时间后,我不太明白为什么这不起作用。
编辑
这个问题可能比我想象的要简单:
如果我尝试:
Key<GameBoard> a = mFourByFourBoardKeys.get(0);
Run Code Online (Sandbox Code Playgroud)
我得到:
类型不匹配:无法从 转换
Key<FourByFourBoard>为Key<GameBoard>
虽然:
GameBoard someBoard = new FourByFourBoard();
Run Code Online (Sandbox Code Playgroud)
是合法的。所以这仍然是一个泛型问题,但集合部分并不重要。我的头仍然有点旋转。
我发现当我初始化一个新的子类时,我得到了返回的父类的对象。
家长:
- (id)init
{
self = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"EditController"];
return self;
}
Run Code Online (Sandbox Code Playgroud)
孩子:
- (id)init
{
NSLog(@"New child");
self = [super init];
return self;
}
Run Code Online (Sandbox Code Playgroud)
如果我分配并初始化一个子级,它会显示New child但会返回父级类的对象。调用仅在子级中声明的方法会导致崩溃。
有人可以解释一下初始化过程是如何工作的,以及如何创建子对象吗?
我正在使用 JDBC 更新 MySQL 数据库中的一行:
pConnection.setAutoCommit(true);
PreparedStatement pstmt = pConnection.prepareStatement("update mg_build_queue " + //
"set buildsetid=?,locale=?,areacode=?,distversionid=?,platformid=?,version=?," + //
"priority=?,buildstatus=?,computername=?,buildoutput=?,started=?,finished=?, packageid=?, lockcounter=0 where buildid=?" //
);
pstmt.setInt(1, mBuildSet.getId());
pstmt.setString(2, Locale.localesToString(mLocales, ","));
pstmt.setString(3, mAreaCode.toString());
pstmt.setInt(4, mDistVersionId);
pstmt.setInt(5, mPlatform);
pstmt.setInt(6, mVersion);
pstmt.setLong(7, mPriority);
pstmt.setInt(8, mBuildStatus);
pstmt.setString(9, mComputerName);
pstmt.setString(10, mBuildOutput);
pstmt.setTimestamp(11, timeToTimestamp(mStarted));
pstmt.setTimestamp(12, timeToTimestamp(mFinished));
pstmt.setInt(13, mResultPackageId);
pstmt.setInt(14, mBuildId);
LOGGER.debug("Updating data for mg_build_queue: " + pstmt);
pstmt.execute();
LOGGER.debug("Updated " + pstmt.getUpdateCount() + " rows.");
Run Code Online (Sandbox Code Playgroud)
这会生成以下输出:
2012-05-24 09:54:33,211 [Thread-1] DEBUG com.buildmaster.BuildQueueEntryImpl - Updating data for mg_build_queue: …Run Code Online (Sandbox Code Playgroud) 我在Game Center中为我的应用程序创建了一个成就,其中英文本地化包含1024 x 1024图形.
我完成了成就,但是当我将我的GKGameCenterViewController标签加载到成就中时,我看到了默认的奖杯图标.英文文本是正确的.我处于沙盒模式.
为什么会发生这种情况?
我有一个针对Apple的LLVM 4.2编译器(Base SDK 6.1)编译的库.在其中有对象下标.
想象一下,我的库只有一个类有一个方法.那个方法做到了这个:
NSLog(@"****** preTests");
NSDictionary *dictTest = @{ @1 : @1 };
NSLog(@"Initialized Dictionary");
NSArray *arrayTest = @[ @1, @2, @3 ];
NSLog(@"Initialized Array");
NSLog(@"****** arrayTest[1] = %@", arrayTest[1]); // First use of subscripting
NSLog(@"****** dictTest[@1] = %@", dictTest[@1]);
Run Code Online (Sandbox Code Playgroud)
现在我创建一个新项目并链接此库.在我的应用程序委托中,我调用此方法.我使用GCC LLVM 4.2编译器编译此应用程序.它编译和链接很好.
此应用程序将在iOS 6+上无错误运行.此应用程序将在iOS 5的"首次使用下标"(上图)中崩溃.
2013-07-03 09:15:51.050 GCCTest[167:707] -[__NSArrayI objectAtIndexedSubscript:]: unrecognized selector sent to instance 0x381fb0
Run Code Online (Sandbox Code Playgroud)
使用Apple LLVM 4.2编译器对其进行编译,它将正常运行.
objectAtIndexedSubscript:是一种在iOS 6中公开发布的方法,我的理解是它的语法糖myArray[0]被翻译成了什么.
有人可以帮助我理解为什么我看到GCC崩溃而不是苹果与iOS 5崩溃?我猜它与某些地方的某些宏有关...如果不编辑我的库代码,这可能会导致GCC崩溃吗?
在处理通用链接时,我打算实现:
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType
Run Code Online (Sandbox Code Playgroud)
在处理我使用的传统 URL 方案时:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
Run Code Online (Sandbox Code Playgroud)
如何从前一种方法获取源应用程序?
我认为'rvalue'只是返回值的简写.初始化返回对象意味着什么?这是我的主要问题.其余的是我特殊情况的背景,但我真的对一般答案感兴趣.
我正在看别人的代码:
return [p_facebook.facebook handleOpenURL:url];
Run Code Online (Sandbox Code Playgroud)
理论上这是在呼唤:
- (BOOL)handleOpenURL:(NSURL *)url;
Run Code Online (Sandbox Code Playgroud)
我看到了:Cannot initialize return object of type 'BOOL' (aka 'signed char') with an rvalue of type 'id'.我猜这个类可能在其他地方定义,我有路径问题......
getServingUrl是从AppEngine数据存储区获取图像的便捷方式,但它似乎想要自动转换图像.
例如,如果我这样做:
ServingUrlOptions servingUrlOptions = ServingUrlOptions.Builder.withBlobKey(blobKey);
String payload = "{ \"image\" : \"" + mImagesService.getServingUrl(servingUrlOptions) + "\" }";
Run Code Online (Sandbox Code Playgroud)
我得到一个尺寸调整大小的图片的URL.例如,如果我上传960 x 640图像,默认网址会指向512 x 341图像.
所以,你说,在URL中应用一个变换并设置s960.这确实返回了一个960 x 640的图像,但它已被转换 - 如果将它与原始图像进行比较,您可以在图像中看到伪像.
服务器正在适当地存储图像,这要归功于我在这里找到一种原始尺寸裁剪的技术:
Image image = ImagesServiceFactory.makeImageFromBlob(blobKey);
Transform noOpCrop = ImagesServiceFactory.makeCrop(0, 0, 1, 1);
image = mImagesService.applyTransform(noOpCrop, image);
LOGGER.info("Stored image " + image.getWidth() + ", " + image.getHeight());
Run Code Online (Sandbox Code Playgroud)
我实际上并没有查看它是否包含原始字节,但它并不重要,因为如果我要回发送字节,我不妨直接从商店中取出数据并将其设置为自定义映像服务servlet的有效负载.
写这个我意识到这听起来更像是一个功能请求而不是一个问题,所以我会这样说:服务原始图像比通过自定义servlet有更好的解决方案吗?
这是一个错误还是这里有一个微妙的教训?
NSNumber *someNumber = @(1);
[someNumber respondsToSelector:@selector(mutableCopy)]; // returns YES (!)
[someNumber respondsToSelector:@selector(mutableCopyWithZone:)]; // returns NO
Run Code Online (Sandbox Code Playgroud)
Apple LLVM 7.1(iOS SDK 9.3)
objective-c ×4
ios ×2
java ×2
applescript ×1
cocoa-touch ×1
game-center ×1
generics ×1
jdbc ×1
llvm ×1
llvm-gcc ×1
macos ×1
mutability ×1
mysql ×1
nsnumber ×1
safari ×1
sql-update ×1
uistoryboard ×1