我想从我的iPhone应用程序中删除表中的所有行.我正在使用以下代码,但它没有删除数据:
+(void)emptyData:(NSString*)dbPath{
NSString *query = @"delete from survey_question_responses";
const char *sqlStatement = [query UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSLog(@"result is here");
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用AFNetworking通过SSL发送数据.如何防止中间人攻击?我如何确定我收到并将数据发送到我的服务器而不是其他服务器?
这是我的代码:
@implementation API
@synthesize user;
#pragma mark - Singleton methods
/**
* Singleton methods
*/
+(API*)sharedInstance
{
static API *sharedInstance = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
sharedInstance = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAPIHost]];
});
return sharedInstance;
}
#pragma mark - init
//intialize the API class with the destination host name
-(API*)init
{
//call super init
self = [super init];
if (self != nil) {
//initialize the object
user = nil;
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
[self setDefaultHeader:@"Accept" value:@"application/json"];
}
return self; …
Run Code Online (Sandbox Code Playgroud) 我的数据看起来像这样,其中负号是数字末尾的后缀.
"general_amount"
"0000000441244"
"0000000127769-"
"0000000043819"
"0000000522600-"
Run Code Online (Sandbox Code Playgroud)
有人可以帮我找到正则表达式,以产生下面所需的输出.
"general_amount"
441244
-127769
43819
-522600
Run Code Online (Sandbox Code Playgroud) 我知道Objective-C不支持方法重载.但是,如何理解以下与'tableView'同名的委托方法?对我来说,这些方法似乎超载了,但我不确定.
对于视图控制器来指示它是UITableView委托,它必须实现UITableViewDelegate协议.以下是在视图控制器中实现的常见委托方法:
tableView:heightForRowAtIndexPath:
tableView:willDisplayCell:forRowAtIndexPath:
tableView:didSelectRowAtIndexPath:
tableView:didDeselectRowAtIndexPath:
tableView:commitEditingStyle:forRowAtIndexPath:
tableView:canEditRowAtIndexPath:
Run Code Online (Sandbox Code Playgroud) 我有一个UISwitch
放在我的故事板中并将其连接到我的实现文件中的插座,并将该valueChanged:
方法连接到控制事件"值已更改".但是,只有在我将其从关闭切换为开启时才会调用,而不是从开启切换到关闭.
这是我的代码:
ViewController.h
@interface splitViewController : UIViewController
@property (weak, nonatomic) IBOutlet UISwitch *tipIncluded;
@end
Run Code Online (Sandbox Code Playgroud)
ViewController.m:
- (IBAction)valueChanged:(UISwitch *)sender {
NSLog(@"3");
if (_tipIncluded.isOn==YES){
NSLog(@"2");
_tipIncluded.on=NO;
_tip.text=@"";
_tip.backgroundColor = [UIColor whiteColor];
}
if (_tipIncluded.isOn==NO){
NSLog(@"1");
_tipIncluded.on=YES;
_tip.text=@"0";
_tip.backgroundColor = [UIColor lightGrayColor];
_tip.textColor = [UIColor blackColor];
}
}
Run Code Online (Sandbox Code Playgroud)
我知道它只是在从off变为on时才调用这个方法,因为当我以这种方式切换时,我只在方法结束时从NSLog获得3.
如果我有像"How are you doing ?"
或的字符串"I am fine ."
我怎样才能得到 -
"How are you doing?"
要么 "I am fine."
我想删除最后一个单词和"?"之间的空格.要么 "."
有没有人知道在Haskell中转换形式的东西的方法
["w","o","r","d"]
Run Code Online (Sandbox Code Playgroud)
成
word
Run Code Online (Sandbox Code Playgroud)
我刚刚完成了我的第一个程序(一个RSA加密),此刻的输出真的很难看.如果这是一个非常愚蠢的问题,我很抱歉,但我真的不知道如何去做.此外,为了使我的输入更容易,有没有人知道转换的方式
word
Run Code Online (Sandbox Code Playgroud)
成
[w,o,r,d]
Run Code Online (Sandbox Code Playgroud) 我想在我当前的日期添加3个小时.我使用以下代码添加小时数,但它增加了6个小时到当前日期.
NSDate *n = [NSDate date];
int daysToAdd = 3; // or 60 :-)
// set up date components
NSDateComponents *components1 = [[[NSDateComponents alloc] init] autorelease];
[components1 setHour:daysToAdd];
// create a calendar
NSCalendar *gregorian12 = [NSCalendar currentCalendar];
NSDate *newDate2 = [gregorian12 dateByAddingComponents:components toDate:n options:0];
NSLog(@"Clean: %@", newDate2);
Run Code Online (Sandbox Code Playgroud)
结果是: -
2013-09-10 12:25:24.752 project[1554:c07] Clean: 2013-09-10 06:55:15 +0000
Run Code Online (Sandbox Code Playgroud) 我一直在使用以下代码,几乎没有任何问题,但今天Xcode开始抱怨它BIGTIME.在我发现错误/内存泄漏之前,我几乎疯了.Xcode表示"消息已发送到解除分配的实例".我评论了几行(发行版),它停止了崩溃.
问题是,我完全迷失在这里......我不应该释放那些以避免内存泄漏吗?我的目标是针对这个项目的iOS 4.0,所以手动内存管理是必须的.
+ (NSString*)reformatRule:(NSString*) ruleStr {
NSString *bufRule = [[[NSString alloc] init] autorelease];
NSString *buf = [[NSString alloc] init];
char c = 0;
NSString *value = [[NSString alloc] init];
for(int i=0;i<[ruleStr length];i++){
c = [ruleStr characterAtIndex:i];
if([self isCharacterOrDigit:[NSString stringWithFormat:@"%c",c]]){
buf = [buf stringByAppendingString:[NSString stringWithFormat:@"%c",c]];
}else{
DLog(@"says:%@",buf);
value = [buf stringByReplacingOccurrencesOfString:@" " withString:@""];
//[buf release];
//buf = [[NSString alloc] init];
buf = @"";
if (![value isEqualToString:@""]) {
if ([value isEqualToString:CONDITION_AND] || [value isEqualToString:CONDITION_OR]) {
bufRule = [bufRule stringByAppendingString:[NSString stringWithFormat:@"%@",value]];
}else{ …
Run Code Online (Sandbox Code Playgroud) 我正在使用Aquamacs,我有Java版本8.我的OSX版本是Mavericks.
这是我的代码:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我编译它的方式:
Nayans-MacBook-Pro:~ nghosh$ javac HelloWorld.java
javac: file not found: HelloWorld.java
Usage: javac <options> <source files>
use -help for a list of possible options
Run Code Online (Sandbox Code Playgroud)
有什么建议?
这是我的简单程序
char *array = 1==1;
if((bool)array == true)
printf("true");
Output: true
Run Code Online (Sandbox Code Playgroud)
但是当我更改数组时
*array = 1==2;
Output: true
Run Code Online (Sandbox Code Playgroud)
我不知道为什么总是如此.我只想打印变量中的字符串array
是否为true
或false
.
ios ×6
objective-c ×5
iphone ×2
afnetworking ×1
boolean ×1
c ×1
cocoa ×1
cocoa-touch ×1
haskell ×1
ios4 ×1
java ×1
list ×1
nscalendar ×1
nsdate ×1
nsstring ×1
output ×1
r ×1
regex ×1
sqlite ×1
uiswitch ×1