我正在尝试使用shell脚本获取目录的内容.
我的脚本是:
for entry in `ls $search_dir`; do
echo $entry
done
Run Code Online (Sandbox Code Playgroud)
哪里$search_dir
是相对路径.但是,它$search_dir
包含许多名称中带有空格的文件.在这种情况下,此脚本不会按预期运行.
我知道我可以使用for entry in *
,但这只适用于我当前的目录.
我知道我可以更改到该目录,for entry in *
然后使用然后更改回来,但我的特殊情况阻止我这样做.
我有两个相对路径$search_dir
和$work_dir
,和我有两个同时工作,阅读他们创建/删除在他们的文件等.
那我现在该怎么办?
PS:我用bash.
给定目录[[self documentsDirectory] stringByAppendingPathComponent:@"Photos/"]
如何删除此文件夹中的所有文件?
(假设文档目录路径正确)
我在使用Gson序列化对象时遇到问题.
@XmlRootElement
class Foo implements Serializable {
private int number;
private String str;
public Foo() {
number = 10;
str = "hello";
}
}
Run Code Online (Sandbox Code Playgroud)
Gson会将其序列化为JSON
{"number":10,"str":"hello"}
.
但是,我希望它是
{"Foo":{"number":10,"str":"hello"}}
,
所以基本上包括顶级元素.我试图谷歌一种方式在Gson做到这一点,但没有运气.任何人都知道是否有办法实现这一目标?
谢谢!
嘿伙计们,快速问题,我有这个查询,我正在尝试获取每个主题的最新评论,然后按降序排序这些结果(因此每个主题一个评论).我有我认为应该工作的东西,但我的加入总是让我的结果变得混乱.不知何故,它似乎已经正确地对最终结果进行了排序,但没有从每个主题中获取最新评论,而是似乎只是随机评论.如果有人有任何想法,真的很感激任何建议
SELECT * FROM comments
JOIN topic ON topic.topic_id=comments.topic_id
WHERE topic.creator='admin'
GROUP BY comments.topic_id
ORDER BY comments.time DESC
Run Code Online (Sandbox Code Playgroud)
表注释的结构类似于
id time用户消息topic_id
表主题的结构类似于
topic_id subject_id topic_title创建者时间戳描述
我有这个功能:
int setIncludes(char *includes[]);
Run Code Online (Sandbox Code Playgroud)
我不知道includes
会有多少价值.它可能需要includes[5]
,可能需要includes[500]
.那么我可以使用什么功能来获得长度includes
?
我想开发一个使用外部硬件插件的iOS应用程序,有点像Square https://squareup.com.但是我无法在Apple的文档中找到任何引用.有人能指出我正确的方向吗?
我正在尝试使用自签名证书来处理我的应用程序.
我现在正在使用ASIHTTPRequest库,如下所示:
- (IBAction)sendHttpsRequest
{
//Set request address
NSMutableString *databaseURL = [[NSMutableString alloc] initWithString:@"https://142.18.87.46:443"];
//call ASIHTTP delegates (Used to connect to database)
NSURL *url = [NSURL URLWithString:databaseURL];
//This sets up all other request
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request setValidatesSecureCertificate:YES];
[request startAsynchronous];
}
Run Code Online (Sandbox Code Playgroud)
我已经将setValidatesSecureCertificate设置为YES,希望会发生一些事情,但显然什么都没有,因为我不确定我必须做什么.
这是我在日志中收到的错误
2011-12-06 14:27:33.514 connectionTest[916:207] Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred: SSL problem (Possible causes may include a bad/expired/self-signed certificate, clock set to wrong date)" UserInfo=0x683a860 {NSUnderlyingError=0x68390d0 "The operation couldn’t be completed. (OSStatus error …
Run Code Online (Sandbox Code Playgroud) 假设我有一个UIViewController子类来处理一些UIViews.这些UIViews被添加为UIViewController view
属性的子视图):
UIViewController中:
- (void)viewDidLoad {
UIImageView *smallImageView...
[self.view addSubview:smallImageView];
UIButton *button..
[self.view addSubview:button];
UIView *bigUIView.. // covers the entire screen (frame = (0.0, 0.0, 1024.0, 768.0))
[self.view addSubview:bigUIView];
...
}
Run Code Online (Sandbox Code Playgroud)
AFAIK,因为它bigUIView
是最前面的视图并覆盖整个屏幕,它将接收touchesBegan:withEvent:
和其他视图,例如button
不会接收任何触摸事件.
在我的应用程序中bigUIView
必须是最顶层的视图,因为它包含主要的用户界面对象(CALayers,实际上是主要的游戏对象),在动画时,必须位于所有其他辅助UI元素(UIButtons等)之上.但是,我希望能够在响应程序链中保留UIButtons和其他对象.
我尝试在bigUIView
课堂上实现以下内容:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.superview touchesBegan:touches withEvent:event];
... hit test the touch for this specific uiview..
}
Run Code Online (Sandbox Code Playgroud)
笔记:
bigUIView
的superview引用了UIViewController的view
属性,它是否将触摸事件传播到它的所有子视图?bigUIView
必须有,userInteractionEnabled = YES
因为它也处理用户输入.button
/ smallImageView
带到前面,因为它会出现在主要游戏对象(子层 …我对Objective-C有点新,但遇到了一个我无法解决的问题,主要是因为我不确定我是否正确实现了解决方案.
我正在尝试使用同步连接连接到具有自签名证书的https站点.我得到了
错误域= NSURLErrorDomain代码= -1202"不受信任的服务器证书"
我在这个论坛上看到了一些解决方案的错误.我找到的解决方案是添加:
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
}
Run Code Online (Sandbox Code Playgroud)
到NSURLDelegate接受所有证书.当我使用以下内容连接到网站时:
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://examplesite.com/"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
Run Code Online (Sandbox Code Playgroud)
它工作正常,我看到挑战被接受.但是,当我尝试使用同步连接进行连接时,我仍然会收到错误,并且当我输入日志记录时,我看不到调用挑战函数.
如何使用同步连接来使用质询方法?是否与委托有关:URLConnection的自我部分?我还有在NSURLDelegate中发送/接收数据的日志记录,该数据由我的连接函数调用,但不是由同步函数调用.
我用于同步部分的内容:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:@"https://examplesite.com/"]];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: [[NSString stringWithString:@"username=mike"] dataUsingEncoding: NSUTF8StringEncoding]];
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"%@", error);
stringReply = [[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding];
NSLog(@"%@", stringReply);
[stringReply release];
NSLog(@"Done");
Run Code Online (Sandbox Code Playgroud)
就像我提到的,我对目标C有点新意,所以要善待:)
谢谢你的帮助.麦克风
我的Java脚本由2 Java类:RMS
,queryRMS
在RMS
I类调用该方法的queryRMS
类
RMS Java类(我省略了开始执行部分,下面只是方法)
for (int i = 1; i <= itemCount; i++) {
GlobalVariables.numberRow = i;
JavaDatapool.settings();
String item = queryRPM.connectDB_Multi(configFile,"SELECT ITEM FROM ORDSKU WHERE ORDER_NO = '" + orderNo + "' ORDER BY ITEM ASC",i);
JavaDatapool.writeXLS("item",item,GlobalVariables.sheetXLS);
sleep(1);
}
Run Code Online (Sandbox Code Playgroud)
queryRMS JAVA类
public static String connectDB_Multi(String configFile, String query, int i) throws FileNotFoundException, IOException, SQLException, ClassNotFoundException{
Properties p = new Properties();
p.load(new FileInputStream(configFile));
String serverName = (p.getProperty("RMS_DBServerName"));
String portNumber = (p.getProperty("RMS_PortNumber"));
String …
Run Code Online (Sandbox Code Playgroud) iphone ×4
ios ×2
java ×2
objective-c ×2
arrays ×1
bash ×1
c ×1
cocoa-touch ×1
filesystems ×1
gson ×1
ipad ×1
json ×1
mysql ×1
oracle ×1
pointers ×1
rft ×1
shell ×1
ssl ×1
synchronous ×1
touch ×1
uiresponder ×1
uiview ×1
xcode ×1