问候,
我试图简单地将NSString与NSArray进行比较.
这是我的代码:
NSString *username=uname.text;
NSString *regex=@"^[a-zA-Z0-9-_.]{3,20}$";
NSArray *matchArray=nil;
matchArray=[username componentsMatchedByRegex:regex];
if(matchArray[0] == "asdf"){ //this line causes the problem!
NSLog(@"matchArray %@",matchArray);
}
Run Code Online (Sandbox Code Playgroud)
我得到"无效的操作数到二进制=="错误.
我该如何比较字符串?
提前谢谢了,
问候,
我正在尝试编写我的第一个iPhone应用程序.我需要能够访问所有视图中的数据.用户登录时存储数据,此后需要对所有视图可用.
我想创建一个静态类,但是当我尝试访问静态类时,我的应用程序在控制台上没有输出时崩溃了.
是将数据写入文件的唯一方法吗?或者是否有其他我没有想到的清洁解决方案?
提前谢谢了,
我认为这是一个相对简单的事情:用"斜杠"附加"www.google.ie",并用"http://"预先挂起,产生一个值为"http://"的字符串www.google.ie/".不,这不是作业...(我知道)
现在这是我的代码:
std::string line=split1[0]; //split1[0] is "Host: www.google.ie"
std::vector<std::string> split2;
boost::split(split2,line,boost::is_any_of(" "));
boost::erase_all(split2[1],"\n");
std::cout<<"split2[1]:"<<split2[1]<<std::endl; //outputs www.google.ie ok
fURL="http://"+split2[1]+"/";
//fURL="http://www.google.ie/"; //this is what I want fURL to be!
std::cout<<std::endl; //just for some testing
std::cout<<std::endl;
std::cout<<std::endl;
std::cout<<std::endl;
std::cout<<std::endl;
std::cout<<"fURL:"<<fURL<<std::endl; //should output: http://www.google.ie/?
Run Code Online (Sandbox Code Playgroud)
这是我奇怪的输出:
Run Code Online (Sandbox Code Playgroud)split2[1]:www.google.ie /URL:http://www.google.ie
我不知道'/ URL:'中的'/'来自哪里.就好像我指定的尾部斜线以某种方式被固定在前面.我真的不明白这是怎么可能的......
在Linux Ubuntu上使用g ++ 4.5.2.
任何见解都非常感激.
提前谢谢了,
我正试图在XCode 4.1中填充一个简单的uitableview.
这是MessagesInbox.h:
#import <UIKit/UIKit.h>
@interface MessagesInbox : UITableViewController <UITableViewDelegate,UITableViewDataSource>{
NSMutableArray *listData;
IBOutlet UITableView *table;
}
@property (nonatomic,retain) UITableView *table;
@property (nonatomic, retain) NSArray *listData;
@end
Run Code Online (Sandbox Code Playgroud)
这是MessagesInbox.m:
#import "MessagesInbox.h"
@implementation MessagesInbox
@synthesize listData,table;
- (void)loadView{
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
} …Run Code Online (Sandbox Code Playgroud) 我需要'在字符串中找到所有符号,然后从字符串的开头提取所有字符到第一次出现'.例如:我有Jon's,我需要得到Jon.谁能帮助我?
所以我有这个bash脚本来加密:
#!/bin/bash
#encrypt.sh
fn=$1
if [ $# -eq 0 ]
then
echo "Filename required..."
fi
echo "Type text. Hit Ctrl-d when done"
keyvariable=$(cat)
echo -e $keyvariable | gpg --symmetric --cipher-algo AES256 > $fn
Run Code Online (Sandbox Code Playgroud)
我有这个脚本来做解密:
#!/bin/bash
#decrypt.sh
fn=$1
if [ $# -eq 0 ]
then
echo "Filename required..."
fi
cat $fn | gpg --decrypt
Run Code Online (Sandbox Code Playgroud)
例:
sh encrypt.sh test
Type text. Hit Ctrl-d when done
hello
how
are
you
?
Run Code Online (Sandbox Code Playgroud)
我输入密码并确认.太好了.我现在有一个名为"test"的加密文件.
但当我去解密"测试"时,这是输出:
sh decrypt test
gpg: AES256 encrypted data
gpg: encrypted with …Run Code Online (Sandbox Code Playgroud) 我有以下字符串:
HTTP/1.1 200 OK
Date: Tue, 06 Dec 2011 11:53:22 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By: PHP/5.3.2-1ubuntu4.9
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 48
Content-Type: text/html
??(?????I?O????H????????
?4?@??AQ??????t
Run Code Online (Sandbox Code Playgroud)
我想提取"\r\n\r\n",丢弃二进制数据.即:
HTTP/1.1 200 OK
Date: Tue, 06 Dec 2011 11:53:22 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By: PHP/5.3.2-1ubuntu4.9
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 48
Content-Type: text/html
Run Code Online (Sandbox Code Playgroud)
如何在C中执行此操作?