我之前已经将sqlite预先填充的dbs导入我的coredata项目,但现在我已经在3.2.5中创建了一个项目.xcode,在AppDelegate中为nstring更改了nsurl,所以我继续使用它,但是现在我的sqlite没有导入到项目中,
如果我离开我的PersistentStoreCoordinator来创建新的db空白它工作正常,
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"ChildCare_v02.sqlite"];
Run Code Online (Sandbox Code Playgroud)
但是当我更改代码以导入预先填充的数据库(称为相同只是为了澄清)时,它会给我一个警告和崩溃,
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator_ != nil) {
return persistentStoreCoordinator_;
}
NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"ChildCare_v02.sqlite"]; //WARNING !! here
NSURL *storeUrl = [NSURL fileURLWithPath:storePath];
//NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"ChildCare_v02.sqlite"]; //actual SDK style for blank db
// Put down default db if it doesn't already exist
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:storePath]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"ChildCare_v02" ofType:@"sqlite"];
if (defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:storePath …Run Code Online (Sandbox Code Playgroud) 我正在使用我的应用程序上的核心数据,
保存一个应该是整数的数字时出现问题...当我从Core Data中获取它时,它显示奇怪的数值
我知道正在工作,因为通过测试,我的idTosave = 345,它显示了CoreData的结果,但是当发送一个值[string to int]时,我知道它正在记录正确的响应,CD保存了一个奇怪的值:
(请注意我保存到实体idRef)
NSLog(@"resultToDisplay:: %@", self.resultsToDisplay);
// int idToSave = 345; //if I use this line instead of intValue it saves 345 OK!
int idToSave = (int)[self.resultsToDisplay intValue];
NSLog(@"id salvada as NSINTEGER:: %d",idToSave);
//graba a CD!
[Student insertWithDataQR:[studentDataDicto objectForKey:@"name"] surname:[studentDataDicto objectForKey:@"surname"]
phone:[studentDataDicto objectForKey:@""]
dob:[studentDataDicto objectForKey:@"dob"] idRef:idToSave ...]];
[[Student defaultManagedObjectContext]save:nil];
Run Code Online (Sandbox Code Playgroud)
登出:
resultToDisplay:: 1329955200
2012-02-26 00:36:08.597 MyGym_iPad[10867:707] id salvada as NSINTEGER:: 1329955200
Run Code Online (Sandbox Code Playgroud)
注意值1329955200,在保存之前正确显示为整数和字符串,
并检查我做的响应:
NSArray *studiantes = [Student all];
for ( Student *tud in studiantes) { …Run Code Online (Sandbox Code Playgroud) 我在Python中获得此异常,
Exception AttributeError: "'NoneType' object has no attribute 'population'" in del of <main.Robot instance at 0x104eb7098>> ignored
Run Code Online (Sandbox Code Playgroud)
这是我的代码,
class Robot:
population = 0 #class variable, number of robots
def __init__(self, name):
self.name = name
print ('(initializing {0})'.format(self.name))
Robot.population += 1
def __del__(self):
print('{0} is being destroyed!'.format(self.name))
Robot.population -= 1
if Robot.population == 0:
print ('{0} was the last one.'.format(self.name))
else:
print('there are still {0:d} robots working.'.format(Robot.population))
def sayHi(self):
print('hole mi mestre me llama {0}'.format(self.name))
def howMany():
print('hay {0:d} robots'.format(Robot.population))
howMany …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序需要分割视图的两个部分的背景.
如果是整个屏幕1024 x 768,每个部分的大小是多少?
左:w:xx px; h:768px
右:w:xx px; h:768px
我正在实施一个django网站,
该网站转到hello world视图:
views.py /home/ubuntu/djangoProj/micopiloto/portfolio
# Create your views here.
from django.http import HttpResponse
def view(request):
return HttpResponse('Hello Worlsss9d!')
Run Code Online (Sandbox Code Playgroud)
但我看不到amin网站,我看到这个错误: unable to open database file
> http://ec2-107-20-20-19.compute-1.amazonaws.com/admin/
settings.py `/home/ubuntu/djangoProj/micopiloto`
# Django settings for micopiloto project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'thadb.db', # Or path to database file if using sqlite3.
'USER': …Run Code Online (Sandbox Code Playgroud) 我使用单选按钮创建自定义标签主机,工作正常,但现在我需要在顶部显示图标和图标下方的文本,
这就是我现在拥有的:

但这就是我需要的:

这是我的代码:
<RadioButton
android:id="@+id/rad_home"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@drawable/home_icon"
android:gravity="center"
android:text="Home"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" >
</RadioButton>
<RadioButton
android:id="@+id/rad_1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:gravity="center"
android:text="Menu"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" />
<RadioButton
android:id="@+id/rad_2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:gravity="center"
android:text="VIP"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" />
<RadioButton
android:id="@+id/rad_3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:gravity="center"
android:text="About"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" />
<RadioButton
android:id="@+id/rad_4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:gravity="center"
android:text="Whats On"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" />
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
所以即时设置按钮图标:
机器人:按钮="@空"
因为什么时候是空的
和
机器人:按钮= "@绘制/ home_icon"
对于图标图像,我应该使用它来设置图标吗?如何组织它,因为我需要它?[顶部图标,文字底部]
我试过里面的布局,但似乎不喜欢它?
怎么做到这一点?
谢谢!
我有一个NSURLConnection工作,返回可以是字典或数组如何知道什么是响应字典或数组,所以我做了相应的序列化?
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSError* error;
NSDictionary* jsonDicto = [NSJSONSerialization
JSONObjectWithData:self.receivedData
options:kNilOptions
error:&error];
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:self.receivedData
options:kNilOptions
error:&error];
}
Run Code Online (Sandbox Code Playgroud)
干杯.)
我错误地注意到这项工作:
在MyTest.h接口上
- (void):(int)idIndex;
Run Code Online (Sandbox Code Playgroud)
关于实现MyTest.m
- (void):(int)idIndex {}
Run Code Online (Sandbox Code Playgroud)
我甚至可以称之为
[self :2 ];
Run Code Online (Sandbox Code Playgroud)
那么为什么我允许使用没有名字的方法?
对不起,如果是一个奇怪的问题,在我看来只是非常奇怪的行为,欢呼
bool toggle发出警告,
我已经看到要切换Bool,我可以使用
self.calendarIsShowing = !self.calendarIsShowing;
Run Code Online (Sandbox Code Playgroud)
但是我得到了这个警告,
Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *)from 'int'
Run Code Online (Sandbox Code Playgroud)
它仍然有效,我只想修复警告,谢谢
我正在使用JsonObject解析来自API的响应,问题是生成的String具有双引号,如何获取不带引号的字符串?
JsonElement jelement = new JsonParser().parse(response);
JsonObject jobject = jelement.getAsJsonObject();
String authorization = jobject.get("authorization").toString();
Log.d("mensa","parseado jwt :"+authorization);
Run Code Online (Sandbox Code Playgroud)
所以我的回应看起来像...
parseado jwt:“ eyJ0eXAiOiJKV1QiLCJhbGciO ...”
实际的Json回应
{
"authorization": "eyJ0eXAiOiJKV1..."
}
Run Code Online (Sandbox Code Playgroud)
解析此字符串的正确方法是什么,这样我就不会用双引号将其包裹起来?
ios ×5
android ×2
core-data ×2
exception ×2
iphone ×2
objective-c ×2
python ×2
boolean ×1
casting ×1
django ×1
import ×1
jsonobject ×1
radio-button ×1
sqlite ×1
xml ×1