我正试图在我的iPad应用程序的Caches文件夹中存储一些东西.
NSArray* cachePathArray = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString* cachePath = [cachePathArray lastObject];
Run Code Online (Sandbox Code Playgroud)
当我打印出返回的文件路径时,我得到:
/ Users/Gela/Library/Application Support/iPhone Simulator/5.0/Applications/3FF7EB1A-49A9-4B13-ADC4-DF0662BA724B/Library/Caches
但是,当我导航到硬盘驱动器上的该文件夹时,"缓存"不是文件夹,而是模糊的"文档"文件.
任何想法为什么它不是一个文件夹以及如何写入我的缓存?
目前,在我的settings模块中我有这个:
LOGIN_URL = '/login'
Run Code Online (Sandbox Code Playgroud)
如果我决定更改登录URL urls.py,我也必须在此更改.还有更有活力的方法吗?
我正在尝试在django管理员中制作一个django上传进度条.应用程序只是项目的一小部分,因此我不想在settings.py中设置自定义上传处理程序.
upload_handler可以设置,request.upload_handlers.insert(0, UploadProgressHandler(request))但不能在django admin类的add_view中设置.响应是这个例外:
如果您在从request.POST或request.FILES读取后尝试修改request.upload_handlers,Django将抛出错误.
我也试过用装饰器来做这个,add_view但后来我不知道如何访问request.upload_handlers.
有人可以帮我吗?
这是我想要完成的事情 -
到目前为止,我现在需要一个所有子流程都可以访问的共享对象.我正在使用多处理模块中的队列.此外,所有子进程都需要将其输出写入单个文件.我想是一个使用Locks的潜在地方.在我运行时使用此设置,我没有得到任何错误(所以父进程看起来很好),它只是停止.当我按下ctrl-C时,我看到一个追溯(每个子过程一个).也没有输出写入输出文件.这是代码(请注意,没有多个进程,一切运行正常) -
import os
import glob
from multiprocessing import Process, Queue, Pool
data_file = open('out.txt', 'w+')
def worker(task_queue):
for file in iter(task_queue.get, 'STOP'):
data = mine_imdb_page(os.path.join(DATA_DIR, file))
if data:
data_file.write(repr(data)+'\n')
return
def main():
task_queue = Queue()
for file in glob.glob('*.csv'):
task_queue.put(file)
task_queue.put('STOP') # so that worker processes know when to stop
# this is the block of code that needs correction.
if multi_process:
# One way to spawn 4 processes
# pool = Pool(processes=4) …Run Code Online (Sandbox Code Playgroud) 嘿,我需要使用NSDictionary对象数组发出HTTP POST请求.
但是,当我这样做时,我注意到在服务器端,NSDictionary对象没有被反序列化为哈希.它被反序列化为一个字符串 - 这不是我想要的.
这是我从客户端(IPhone)端发送参数的方式:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
for (ABContact *c in contactsWithEmailsOrPhones){
NSString *phoneNumber = [[ABContactsHelper class] contactPhoneNumber:c];
NSString *email = [[c emailArray] objectAtIndex:0];
NSLog(@"looping: %@, %@", phoneNumber, email);
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
phoneNumber,
@"phone",
email,
@"email",
[c firstname],
@"firstname",
[c lastname],
@"lastname", nil];
[request addPostValue:dict forKey:@"contacts[]"];
}
[request setDelegate:self];
[request startAsynchronous];
Run Code Online (Sandbox Code Playgroud)
这是它在服务器(rails)端反序列化时的样子:
Started POST "/app/find_friends" for 67.164.97.48 at Thu Sep 23 14:40:37 -0700 2010
Processing by app#find_friends as HTML
Parameters: {"contacts"=>["{\n email = \"xx\";\n …Run Code Online (Sandbox Code Playgroud) 我收到很多关于指定崩溃的崩溃报告但不知道从哪里开始修复它,因为我无法自己重现它并且崩溃报告是匿名发送的.
你会发现它与NSFetchedResultsController我正在使用的东西有关.
以下是该崩溃报告的摘录.报告之间的唯一区别是索引的范围[...]index (someLargeIndex) beyond bounds (1)[...].其余报告中的其余部分保持不变.
Application Specific Information:
*** Terminating app due to uncaught exception \\\'NSRangeException\\\', reason: \\\'*** -[_PFBatchFaultingArray objectAtIndex:]: index (262144) beyond bounds (1)\\\'
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x31d1e00c __kill + 8
1 libsystem_c.dylib 0x32ac4f95 raise + 17
2 AppName 0x0003d961 uncaught_exception_handler (PLCrashReporter.m:137)
3 CoreFoundation 0x349b57d3 __handleUncaughtException + 239
4 libobjc.A.dylib 0x33f9506b _objc_terminate + 103
5 libstdc++.6.dylib 0x3338ae3d __cxxabiv1::__terminate(void (*)()) + 53
6 libstdc++.6.dylib 0x3338ae91 std::terminate() + 17
7 libstdc++.6.dylib 0x3338af61 __cxa_throw …Run Code Online (Sandbox Code Playgroud) 我正在开发一个带有Ganttchart的小型iPad应用程序,该应用程序将在过去25小时内显示事件.我有5个缩放级别,分别为1小时30分钟,15分钟,5分钟和1分钟.我的细胞宽度为30像素.从每小时的Zoomlevel开始,我有25*30像素= 750宽度的内容(不需要滚动).当缩放单元格宽度保持不变时,只会有更多单元格,我可以水平滚动.它适用于30,15和5分钟.事情发生在1分钟级别(宽度为45000像素(30*1500))时,事情开始出错.滚动视图冻结(我仍然可以滚动,但显示不会更新).
drawRect:已经完成(所以它应该被正确绘制).我可以在按钮上看到一个小滚动条(甚至到达终点).所以我试图警惕宽度,似乎问题从大约16300像素宽度开始.有没有解决这个问题?还是任何一种解决方案?
我使用带有uiview(Ganttchartview)的ScrollView,其中drawRect:我已经超载了.
放大CELL_WIDTH为30且zoomLevels为25,50,75,300,1500
-(IBAction) zoomIn:(id)sender {
self.zoomIndex++;
int width = CELL_WIDTH * [[self.zoomLevels objectAtIndex: self.zoomIndex] intValue];
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, width, self.frame.size.height);
[self.parentView setContentSize: CGSizeMake(self.frame.size.width, self.frame.size.height)];
[self setNeedsDisplay];
}
Run Code Online (Sandbox Code Playgroud)
drawRect绘制线条的位置
Run Code Online (Sandbox Code Playgroud)- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGContextSetLineWidth(context, 2.0);
int interval = [[self.zoomLevels objectAtIndex: self.zoomIndex] intValue];
int width = CELL_WIDTH;
for (int i = 0; i < interval; i++) {
CGContextMoveToPoint(context, width * (i +1), START_AT);
CGContextAddLineToPoint(context, width * (i +1), rect.size.height);
CGContextStrokePath(context);
}
for …Run Code Online (Sandbox Code Playgroud) 有没有办法选择UISearchBar中的所有文本?我尝试了[searchBar selectALL:],但它抛出了信号(无法识别的选择器).
我想允许用户更改以前的搜索文本.在某个时候,当用户刚刚开始输入新请求时,旧的请求应该被解雇.如何实现它的标准方法 - 在文本开始编辑时选择所有文本.
我在这里有一个问题,我做了"gunicorn_django",但它说 "ImportError: No module named registration"
但是,当我这样做时python manage.py run_gunicorn,它运行得很好.
我确认gunicorn_django和注册都在同一个环境中的一种方法是,当我停用它时,我运行gunicorn_django,它返回未找到的命令,当我做python并尝试导入注册时,它找不到.
但是,当我使用virtualenv"workon projectname"时,"gunicorn_django"和"import registration"都有效.
我能做什么?请帮忙.
如何为UIImageView进行简单的位置更改.可以说当前坐标是x:20和y:30
我想把它移到x:100和y:100.
是否可以做动作动画?
ios ×5
objective-c ×5
python ×4
django ×3
iphone ×3
animation ×1
caching ×1
cocoa-touch ×1
contentsize ×1
core-data ×1
django-admin ×1
django-urls ×1
file-upload ×1
gunicorn ×1
ipad ×1
queue ×1
selectall ×1
uiimageview ×1
uiscrollview ×1
uisearchbar ×1
xcode ×1