在objective-c中使用ivars和属性的这三种方式之间的语义差异是什么?
1.
@class MyOtherObject;
@interface MyObject {
}
@property (nonatomic, retain) MyOtherObject *otherObj;
Run Code Online (Sandbox Code Playgroud)
2.
#import "MyOtherObject.h"
@interface MyObject {
MyOtherObject *otherObj;
}
@property (nonatomic, retain) MyOtherObject *otherObj;
Run Code Online (Sandbox Code Playgroud)
3.
#import "MyOtherObject.h"
@interface MyObject {
MyOtherObject *otherObj;
}
Run Code Online (Sandbox Code Playgroud) 从macports之外的源码构建是一件轻而易举的事.使用macports构建需要永远,并且似乎每隔一段时间就冻结os.这是典型的行为吗?虽然它似乎是一个很好的os x包装工具,如果我每次安装时都要经历这种痛苦,我想我会没有它.
我注意到Exception.pm和Error.pm似乎没有在Perl社区中广泛使用.这是因为eval
异常处理的占地面积很大吗?
此外,Perl程序似乎对一般的异常处理有一个更宽松的政策.这是否有令人信服的理由?
无论如何,Perl中最好的异常处理方法是什么?
是否存在从列表中仅获取某些值的"pythonic"方式,类似于此perl代码:
my ($one,$four,$ten) = line.split(/,/)[1,4,10]
Run Code Online (Sandbox Code Playgroud) 好吧,也许我错过了一些非常简单的事情,如果是这样的话我会道歉,但是,我已经搜索了标题的每一个排列并且没有找到!所以这就是我想要做的事情:当选择该行时,将我正在使用的标签的背景颜色更改为2组件选择器视图中的行视图.所以我认为这会奏效:
if (row == [pickerview selectedRowForComponent])
viewlabel.backgroundColor = redcolor;
Run Code Online (Sandbox Code Playgroud)
但这不起作用.它似乎随意选择要着色的行,有时甚至会给出错误的访问错误.我试过所有不同的条款都没有效果!任何建议将不胜感激!!
这是完整的方法:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
if (component == kNumberComponent) {
#define PICKER_LABEL_FONT_SIZE 24
#define PICKER_LABEL_ALPHA 1.0
// UIFont *font = [UIFont boldSystemFontOfSize:PICKER_LABEL_FONT_SIZE];
UIFont *font = [ UIFont fontWithName:@"AppleGothic" size:24];
UILabel *carsLabel =[ [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 75, 50) ]autorelease];
//[picker selectRow:row inComponent:component animated:YES];
NSString *pickerText = [self.numbers objectAtIndex:(int)row];
carsLabel.text = pickerText;
carsLabel.textAlignment = UITextAlignmentCenter;
NSLog(@"carsLabel = %@",carsLabel.text);
//carsLabel.text = @"maybe because the string isn't long …
Run Code Online (Sandbox Code Playgroud) 我被要求推荐一种资源(在线,书籍或教程)来学习非CS或数学专业的算法(在麻省理工学院的算法简介的意义上).显然麻省理工学院的书太过复杂,而且一些较轻的处理方法(如OReilly的Nutshell算法)似乎仍然需要在算法分析方面有一些背景知识.是否有资源以某种方式呈现材料,使得没有理论计算机科学背景的开发人员会觉得有用?
是否存在为iPhone应用程序存储持久静态数据的"最佳实践"方法?
我有一个应用程序,它读取大约1000个项目的字典,其中许多是数组.我开始使用单个plist,它变得有点笨拙,特别是因为很多值都是HTML字符串.
我有更好的方法来解决这个问题吗?我计划大幅度扩展这个应用程序,我显然不想在中途改变我的方法.
我已经google了iphone data storage
和变种,但是对于任何甚至触及最佳实践的任何事情都做得很短.
我正在尝试使用此viewDidLoad方法获取用户当前的纬度和经度.生成的映射正确指示当前位置,但NSLog始终显示:
2009-09-19 16:45:29.765 Mapper[671:207] user latitude = 0.000000
2009-09-19 16:45:29.772 Mapper[671:207] user longitude = 0.000000
Run Code Online (Sandbox Code Playgroud)
谁知道我在这里失踪了什么?在此先感谢您的帮助!
- (void)viewDidLoad {
[super viewDidLoad];
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
[mapView setShowsUserLocation:YES];
CLLocation *userLoc = mapView.userLocation.location;
CLLocationCoordinate2D userCoordinate = userLoc.coordinate;
NSLog(@"user latitude = %f",userCoordinate.latitude);
NSLog(@"user longitude = %f",userCoordinate.longitude);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Damian Conway的"由内而外"的对象,如他所描述的那本精彩的书Perl Best Practices,用于在我的客户端构建面向对象的安全系统接口.我想在我的模块中使用内部帮助器方法,我通常将其指定为"_some_method".但是,这似乎打破了封装,因为它们可以通过包名直接调用.有没有办法让这些方法真正私密?举个例子,
use SOD::MyOOInterface;
my $instance1 = SOD::MyOOInterface->new();
$instance1->_some_method; #this produces an error:
SOD::MyOOInterface::_some_method; # this results in a
# successful method call
Run Code Online (Sandbox Code Playgroud)
显然我不希望_some_method的直接调用成功.有什么方法可以保证吗?
iphone ×3
objective-c ×2
perl ×2
algorithm ×1
coordinates ×1
debugging ×1
eval ×1
installation ×1
ios ×1
list ×1
macos ×1
macports ×1
mapkit ×1
nsthread ×1
oop ×1
plist ×1
properties ×1
python ×1
sqlite ×1
uipickerview ×1