我遇到了这个术语Hindley-Milner,我不确定是否掌握了它的含义.
我看过以下帖子:
但是维基百科中没有单一的条目,通常会给我一个简明的解释.
注意 - 现在添加了一个
它是什么?
哪些语言和工具实现或使用它?
你能提供一个简明的答案吗?
一个iPhone应用程序,通过TCP连接到远程服务器.使用场景是:
假设如果应用程序30分钟内没有向服务器发送数据,服务器将关闭连接.即使用户什么也不做,我想让连接保持120分钟.
案例1:如果应用程序在前台,我可以使用计时器向服务器发送一些无用数据.没问题.
案例2:如果用户按下主页并且应用程序转到后台,我该怎么办?我不想表现出警告或某些事情来打断用户(他不在或正在玩游戏).我只想让连接保持更长时间,当用户回到应用程序时,他发现连接仍然存在并且对此感到满意.
我已阅读有关iphone API的后台执行,多任务处理和本地通知的文档.我不确定能否达到案例2.
仅使用合法的API,不进行越狱.
在这段视频中,Rich Hickey为Lisp程序员介绍了Clojure.
在时间01:10:42,他在Clojure/Common Lisp/Scheme/Java中讨论了nil/false/end-of-sequence /'().他说:"计划是真实的,但它们是破碎的."
我不明白他为什么这么说,为什么他认为它"破碎"了?
当UITextField什么都不包含时,按下键盘的删除键不会调用任何UITextFieldDelegate的方法.
我该如何检测它?
编辑:似乎没有简单的方法来做到这一点.我能找到的最有用的链接是:
简而言之,我的解决方案是在文本字段的开头放置一个永久的SPACE.并进行其他nesessary更改(textFieldShouldReturn:,textField:shouldChangeCharactersInRange:replacementString:,等).
Common Lisp HyperSpec表示不推荐使用require和****模块****.
但我仍然看到我们一直都在使用require.我们应该用什么?
我们可以将UITextField的这个属性设置为"Send","Search","Go"等:
@property(nonatomic) UIReturnKeyType returnKeyType
Run Code Online (Sandbox Code Playgroud)
但是在使用UITextField时设置它根本不会改变.
我想要这种行为:当UITextField为空时,让returnKeyType为"Return",否则让returnKeyType为"Send".
在这些方法中,我得到了相应的阶段:
touchesBegan:withEvent:UITouchPhaseBegan,
touchesMoved:withEvent:UITouchPhaseMoved,
touchesEnded:withEvent:UITouchPhaseEnded,
touchesCancelled:withEvent:UITouchPhaseCancelled.
在这个阶段我可以在哪里获得触摸事件:UITouchPhaseStationary?
我刚刚成为 iOS 开发者计划的成员,我正在阅读 iOS 开发者计划用户指南文档。它说:
好吧,在我的 Xcode Organizer 中,我可以看到两个版本:4.2.1(8C148) 和 4.3.2(8H7)。假设我想在以前版本的 iOS(例如 4.0 或 3.x)上测试我的应用程序。我在哪里可以找到/下载文档中所说的 iOS 磁盘映像(固件)?
谢谢。
一个简单的iphone程序,由项目模板基于视图的应用程序生成,带有几个按钮,我添加了以下代码:
- (void) showInfo: (UIView *) view {
NSLog(@"view bounds %6.2f %6.2f %6.2f %6.2f", view.bounds.origin.x, view.bounds.origin.y, view.bounds.size.width, view.bounds.size.height);
NSLog(@"view frame %6.2f %6.2f %6.2f %6.2f", view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
NSLog(@"view center %6.2f %6.2f", view.center.x, view.center.y);
}
- (BOOL)shouldAutorotateToInterfaceOrientation: UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (void)willRotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval) duration {
switch(toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
[self showInfo: self.view];
break;
case UIInterfaceOrientationLandscapeLeft:
[self showInfo: self.view];
break;
case UIInterfaceOrientationLandscapeRight:
[self showInfo: self.view];
break;
}
}
- (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation {
switch(fromInterfaceOrientation) …
Run Code Online (Sandbox Code Playgroud) NSFileManager有一个复制方法.
- (BOOL)copyItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error
Run Code Online (Sandbox Code Playgroud)
如果发生错误,返回时的第三个参数(NSError**)将包含描述问题的NSError对象.
问题:我需要发布它吗?
还有一些其他方法,例如这个方法(NSString**),
NSPropertyListSerialization +(NSData *)dataFromPropertyList:(id)plist format:(NSPropertyListFormat)format errorDescription:(NSString **)errorString
Run Code Online (Sandbox Code Playgroud)
他们遵循相同的内存管理规则吗?要发布或不发布,这就是问题所在.
- -回答
正如安德斯所说,答案是"不"要发布.
我感到困惑,因为NSPropertyListSerialization类有一个方法
+ (NSData *)dataFromPropertyList:(id)plist format:(NSPropertyListFormat)format errorDescription:(NSString **)errorString
Run Code Online (Sandbox Code Playgroud)
文件说如果不是零,我应该释放第三个参数.然而,它被弃用并取而代之
+ (NSData *)dataWithPropertyList:(id)plist format:(NSPropertyListFormat)format options:(NSPropertyListWriteOptions)opt error:(NSError **)error
Run Code Online (Sandbox Code Playgroud)
并且参数现在是(NSError**).无需像其他类似方法一样发布.因此一般的内存管理规则不需要释放这种参数.
---参考文件
在Apple的高级内存管理编程指南中,您不拥有通过引用返回的对象部分:
当您调用这些方法中的任何一个时,您不会创建NSError对象,因此您不拥有它.
iphone ×6
ios ×4
common-lisp ×2
uitextfield ×2
background ×1
clojure ×1
cocoa ×1
cocoa-touch ×1
inference ×1
lisp ×1
null ×1
scheme ×1
types ×1