我有一个关于引用计数的问题.
这是我的构造函数:
- (id)initWithId:(NSString *)graphId;
Run Code Online (Sandbox Code Playgroud)
在另一个类中,我通过以下方式创建一个对象:
GraphViewController *graph =
[[GraphViewController alloc] initWithId:[[NSString alloc] initWithFormat:@"%s", current_ID];
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何正确释放字符串对象?
释放作为参数传递的字符串是否正确?
我班上的代码如下.当我在模拟器上启动我的应用程序时,它可以工作.但是,当在实际设备(iPhone 1g,3.1.3)上启动应用程序时,它不起作用.有任何想法吗?
(这是为了制作渐变背景)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MainScreenCellID = @"MainScreenCellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MainScreenCellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MainScreenCellID] autorelease];
}
cell.textLabel.text = [[[self.controllers objectAtIndex:[indexPath row]] navigationItem] title];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UIImageView *bgimage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell_bg.png"]];
cell.backgroundView = bgimage;
[bgimage release];
for (UIView *view in cell.contentView.subviews) {
view.backgroundColor = [UIColor clearColor];
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)

(添加了黑色字段,因为应用尚未完成.)
编辑:
我可以在UITableViewCell上添加这个方法,我已经创建了自己的子类,但是我使用的是UITableViewDefaultStyle它不起作用.
我正在尝试使用Aptana或RubyMine.我正在使用RVM,所以我可以同时拥有多个版本的Ruby,但是当我在其中任何一个中启动一个新项目时,我得到1.8.7,这不是我想要使用的.我已经安装了最新的1.9.2,我想使用这个版本,我该如何管理呢?(我在命令行中将1.9.2设置为默认值)
我正在制作多个自定义按钮,看起来很像这样:

它是一个简单的按钮,在"指示器视图"中带有绿色或灰色.我需要解释的是:在界面构建器中,按钮可以有四种状态; 正常,突出显示,已选中和已禁用.当我为除了残疾人之外的所有事物提供图像时,我认为正常情况是当按钮上没有触摸时,突出显示的是当你用手指按住它并选择将在释放手指之后.
但是我现在不认为那样.我使用了touch-up-inside事件.我需要在按钮上设置选中/突出显示的etc属性是否正确?
感谢您的时间.
是否可以使用我的iPhone应用程序中的URL将文件保存到Dropbox?
我已经添加了从邮件中将文件作为附件发送的支持,但是如果用户可以选择是否要将其保存在dropbox中,如果应用程序存在于设备上,那将会很酷.
那可以这样做吗?
我最近开始阅读有关Java EE6的内容,在我遵循的示例中,我需要创建远程接口.这样做的目的是什么?我也读过家庭界面,但我不明白.我以前从未做过企业编程,因此我也无法将其与其他内容联系起来.有人可以解释我这些接口吗?
是否存在需要一串文本的API,然后读取它?对于有阅读问题的人来说,这将是一个很酷的功能.然后他们只需点击一个按钮就可以读取它们.
对于在jUnit测试中抛出异常的方法,您如何处理?如您所见,该类中的addAnswer方法Question可能会抛出异常.在shouldFailifTwoAnswerAreCorrect方法中,我想检查是否抛出了异常,但是在shouldAddAnswersToQuestion
我应该MultipleAnswersAreCorrectException从私有addAnswerToQuestion方法中添加throws 并尝试/ catch shouldAddAnswersToQuestion或者在该方法中抛出它吗?
当方法在测试中抛出异常时,你会怎么做?
public class QuestionTest {
private Question question;
@Before
public void setUp() throws Exception {
question = new Question("How many wheels are there on a car?", "car.png");
}
@Test
public void shouldAddAnswersToQuestion() {
addAnswerToQuestion(new Answer("It is 3", false));
addAnswerToQuestion(new Answer("It is 4", true));
addAnswerToQuestion(new Answer("It is 5", false));
addAnswerToQuestion(new Answer("It is 6", false));
assertEquals(4, question.getAnswers().size());
}
@Test(expected = MultipleAnswersAreCorrectException.class)
public void shouldFailIfTwoAnswersAreCorrect() { …Run Code Online (Sandbox Code Playgroud) 我经常听说我不应该id在HTML元素中使用属性来进行CSS中的样式设置.但总是这样吗?假设您的应用程序(ul)中有多个具有类的列表horizontal-list.但是你想为每个ul都应用一些独特的样式,然后添加id并使用它吗?
#food .horizontal-list {
}
#food .horizontal-list li {
}
Run Code Online (Sandbox Code Playgroud)
这里你只用它来分隔元素.或者你应该为每个唯一列表创建一个类."不要id's用于造型目的"只适用于这样使用吗?
#food {
/* loads of attributes */
}
Run Code Online (Sandbox Code Playgroud)
有人可以解释何时可以使用id?