我需要在我的.gitignore
文件中添加一些规则,但是,我在项目文件夹中找不到它.它不是由Xcode自动创建的吗?如果没有,什么命令允许我创建一个?
我没有得到一个优化的正则表达式,它将一个字符串分成第一个空白区域:
var str="72 tocirah sneab";
Run Code Online (Sandbox Code Playgroud)
我需要得到:
[
"72",
"tocirah sneab",
]
Run Code Online (Sandbox Code Playgroud) 我想获取当前位置,但我得到一个错误.
这是我的视图控制器的片段.
- (void)viewDidLoad {
self.locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray<CLLocation *> *)locations {
// I would get the latest location here
// but this method never gets called
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
NSLog(@"didFailWithError: %@", error);
}
Run Code Online (Sandbox Code Playgroud)
我期待委托方法locationManager:didUpdateLocations:
被调用,但只是locationManager:didFailWithError:
被调用,并打印出来:
didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Run Code Online (Sandbox Code Playgroud) 包含一个空格的字符串长度始终等于1:
alert('My str length: ' + str.length);
Run Code Online (Sandbox Code Playgroud)
空间是一个角色,所以:
str = " ";
alert('My str length:' + str.length); // My str length: 3
Run Code Online (Sandbox Code Playgroud)
如何区分空字符串和仅包含空格的字符串?如何检测仅包含空格的字符串?
我有两个表,主题和测验,这是他们的定义:
CREATE TABLE "theme" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "nom" VARCHAR NOT NULL );
CREATE TABLE quiz(
id INTEGER PRIMARY KEY,
nom VARCHAR(256) NOT NULL,
theme INTEGER NOT NULL,
niveau INTEGER NOT NULL,
pass INTEGER DEFAULT 1 NOT NULL,
jok INTEGER DEFAULT 1 NOT NULL,
etat INTEGER DEFAULT 0 NOT NULL,
FOREIGN KEY (theme) REFERENCES theme(id)
);
Run Code Online (Sandbox Code Playgroud)
字段id
在表(主密钥)的主题是一种Foreign Key
在测验表.当我尝试在表测验中插入一个包含值30的记录,例如作为外键时,记录成功地插入到quiz
表中,尽管主题表中没有记录id = 30
,我的意思是,不应该因为我有一个外键约束来拦截这个插入?
当我尝试显示地图时,我得到了这个例外:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region <center:+inf, +0.00000000 span:+1.00000000, +0.50000000>'
Run Code Online (Sandbox Code Playgroud)
我的相关代码是这样的:
-(void)viewWillAppear:(BOOL)animated
{
[mapView removeAnnotations:mapView.annotations];
// locationManager update as location
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
//Configure the new event with information from the location
CLLocationCoordinate2D coordinate = [location coordinate];
latitudeOfUserLocation=coordinate.latitude;
longitudeOfUserLocation=coordinate.longitude;
location2D = (CLLocationCoordinate2D){ .latitude = latitudeOfUserLocation, .longitude = longitudeOfUserLocation };
MyLocation *annotation=[[[MyLocation alloc]initWithName:@"You are here" distanceVersLaStation:@"" coordinate:location2D]autorelease];
annotation.pinColor …
Run Code Online (Sandbox Code Playgroud) 当我尝试将我的应用程序从Xcode启动到设备时,我收到此错误:
error: failed to launch '/Users/Luca/Library/Developer/Xcode/DerivedData/myapp-bmsyknqfiyjuechenbmjnbfmpnsn/Build/Products/Debug-iphoneos/myapp.app/myapp' -- No such file or directory (/Users/Luca/Library/Developer/Xcode/DerivedData/myapp-bmsyknqfiyjuechenbmjnbfmpnsn/Build/Products/Debug-iphoneos/myapp.app/myapp)
Run Code Online (Sandbox Code Playgroud)
我正在为我的iPhone使用Xcode 4.3.2和iOS 5.1.
我的目的是在加载视图时获取用户的经度/纬度,并将值存储在两个变量中以供以后计算.我不需要跟踪用户位置并更新它,我只需要获得他/她的坐标一次.我的代码看起来像这样:
- (void)viewDidLoad {
[super viewDidLoad];
// locationManager update as location
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
// Configure the new event with information from the location
CLLocationCoordinate2D coordinate = [location coordinate];
float longitude=coordinate.longitude;
float latitude=coordinate.latitude;
NSLog(@"dLongitude : %f",longitude);
NSLog(@"dLatitude : %f", latitude);
}
Run Code Online (Sandbox Code Playgroud)
在控制台中我一直这样:
dLongitude : 0.000000
dLatitude : 0.000000
Run Code Online (Sandbox Code Playgroud)
你能帮我吗?
当我尝试构建并运行我的应用程序时,它崩溃了,我在日志中得到了这个:
reason: '[<LoadingViewController 0x6b2c5a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aproposViewController.'
Run Code Online (Sandbox Code Playgroud)
奇怪的aproposViewController
是没有使用LoadingViewController
它,它只是我的应用程序中的另一个视图控制器.请帮忙,提前thx :)
编辑
appdelegate.h:
@class LoadingViewController;
@interface TopStationAppDelegate : NSObject <UIApplicationDelegate,CLLocationManagerDelegate> {
UIWindow *window;
LoadingViewController *loadingView;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet LoadingViewController *loadingView;
@end
Run Code Online (Sandbox Code Playgroud)
appdelegate.m:
#import "LoadingViewController.h"
@implementation TopStationAppDelegate
@synthesize window;
@synthesize loadingView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:loadingView.view];
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[loadingView release];
[window release]; …
Run Code Online (Sandbox Code Playgroud) 标记值是整数:
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:addressField forState:UIControlStateNormal];
[button addTarget:self action:@selector(pickTheQuiz:) forControlEvents:UIControlEventTouchUpInside];
button.tag=1;//or what other integer value, i need to put a string value
Run Code Online (Sandbox Code Playgroud)
在接收方法中:
-(void)pickTheQuiz:(id)sender{
NSLog(@"The part number is:%i",((UIControl*)sender).tag);//i need to receive a string value instead of numeric value
}
Run Code Online (Sandbox Code Playgroud) ios ×6
javascript ×2
cllocation ×1
git ×1
gitignore ×1
iphone ×1
mapkit ×1
objective-c ×1
regex ×1
sqlite ×1
xcode ×1
xcode4.3 ×1