小编NSE*_*rer的帖子

为什么Foundation.h没有在标准Xcode模板中导入?

我刚刚注意到,当我在Xcode(基于视图的应用程序,基于窗口的应用程序等)中使用标准模板创建iPhone应用程序时,头文件只导入UIKit.h(而不是Foundation.h).因此,如果未导入Foundation.h文件,如何在程序中使用NSString,NSArray等基础类?不应该抛出错误吗?

iphone xcode objective-c ios

4
推荐指数
1
解决办法
5753
查看次数

设置属性是否与释放属性相同?

有什么区别

self.myObject = nil;
Run Code Online (Sandbox Code Playgroud)

[myObject release];
Run Code Online (Sandbox Code Playgroud)

另外,为什么前者通常在viewDidUnload方法中使用,后者在dealloc方法中使用?

iphone memory-management objective-c ios

4
推荐指数
1
解决办法
957
查看次数

在UITableViewCell中更改textLabel和detailTextLabel之间的间距?

有没有办法可以在UITableViewCell中更改textLabel和detailTextLabel之间的间距?(没有子类化UITableViewCell)

iphone objective-c uitableview

3
推荐指数
1
解决办法
2306
查看次数

模型类 - 他们真正意味着什么?

我真的无法在MVC中获得模型对象的悬念.我想知道为什么我们不能只使用数组和字典以及字典数组?

我知道它们代表了我的其他类操作和使用的"数据".但他们应该构建的正确方法是什么?假设我有一个我想读的plist并在表视图中显示.我可以直接将它加载到我的viewDidLoad方法中的数组属性中,然后使用它,对吧?我为什么要使用Model类,我将如何构建它?

此外,任何解释这一点的资源/博客链接将不胜感激!

model-view-controller cocoa-touch model objective-c ios

3
推荐指数
1
解决办法
413
查看次数

向一个项目添加静态库时出错

我正在尝试使用示例学习在我的Xcode项目中创建和使用静态库.但是我一直在犯这个错误:

ld: warning: ignoring file /Developer/MathTest/iCodeBlogsMathLibrary/libICodeMathUtils.a,    
missing required architecture i386 in file
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MathFunctions", referenced from:
  objc-class-ref in MathTestViewController.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

我可能会失踪什么?

iphone static-libraries ios xcode4

3
推荐指数
1
解决办法
4702
查看次数

逻辑错误"未定义或垃圾值返回给调用者"

以下陈述有什么问题?

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    NSString *title;

    switch (section)
    {
        case 0:
            title = @"Section 1";
            break;
        case 1:
            title = @"Section 2";
            break;
        default:
            break;
    }

    return title;
}
Run Code Online (Sandbox Code Playgroud)

为什么在分析此代码时会出现"未定义或垃圾值返回给调用者"的逻辑错误?

objective-c ios

2
推荐指数
1
解决办法
2058
查看次数

目标C中的全球财产

我有这样一种在Constants.h文件中定义的枚举:

typedef enum {
    CalendarTypeMonth = 0,
    CalendarTypeWeek
} CalendarType;
Run Code Online (Sandbox Code Playgroud)

然后在我的视图控制器中,我确定日历类型应该是什么,并以这种方式将其存储在属性中:

@property (nonatomic) CalendarType myCalendarType;
Run Code Online (Sandbox Code Playgroud)

现在我希望项目中的所有类都可以访问日历类型.如何将此属性设置为global/extern,以便所有类都可以读取此内容?

编辑:我知道整个项目将提供枚举的定义.但我感兴趣的是价值myCalendarType.如何在所有类中访问myCalendarType的值?

global-variables objective-c ios

2
推荐指数
1
解决办法
8781
查看次数

Objective-C中遇到的最常见/不常见的错误消息是什么?导致它们的原因是什么?

我一直在努力维护一个列表,列出我在开发过程中遇到的所有错误消息及其常见原因和修复.您遇到的常见错误消息(以及不常见的错误消息)是什么?如何修复它们?

iphone debugging objective-c foundation

1
推荐指数
1
解决办法
275
查看次数

双击主页按钮的确是什么?

双击主页按钮的确是什么?

  1. 它是否列出了在后台运行的应用程序,或者
  2. 它列出了最近使用的应用程序吗

我在Info.plist文件中实现了"应用程序不在后台运行".尽管如此,我的应用程序显示双击主页按钮!是的,我尝试过干净的构建.

iphone ios

0
推荐指数
1
解决办法
7263
查看次数

哪些类可以用作NSDictionary中的键?

我们可以只使用NSString对象作为NSDictionary中的键吗?我们如何知道哪些对象可以使用哪些不可以使用?

iphone objective-c foundation ios

0
推荐指数
1
解决办法
467
查看次数

无法继承UITableViewCell

我已经创建了一个UITableViewCell子类,如下所示.我所做的就是在单元格的内容视图中添加一个标签并设置其文本.

#import <UIKit/UIKit.h>
@interface CustomTableViewCell : UITableViewCell {
}
@end

#import "CustomTableViewCell.h" 
@implementation CustomTableViewCell

@synthesize horizontalTableView;

- (id)initWithFrame:(CGRect)frame
{
    if ((self = [super initWithFrame:frame]))
    {

        UIView *myContentView = self.contentView;

        UILabel *l = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 30)];
        l.text = @"Hi";

        [myContentView addSubview:l];

        [l release];
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

现在,我以这种方式在表格视图中使用此自定义单元格:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifier = @"MyCell";

    CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[[CustomTableViewCell alloc] initWithFrame:CGRectMake(0, 0, 50, 300) …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

0
推荐指数
1
解决办法
626
查看次数

无论选择哪一行,indexPathForSelectedRow始终返回0,0

我想替换自定义单元格触摸的单元格.我通过调用reloadRowsAtIndexPaths来做到这一点

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    NSLog(@"Row selected: %d",  [tableView indexPathForSelectedRow] row]);
    NSLog(@"Section selected: %d",  [tableView indexPathForSelectedRow] section]);

    //return a custom cell for the row selected
}
Run Code Online (Sandbox Code Playgroud)

当我尝试从cellForRowAtIndexPath中访问/记录indexPathForSelectedRow时,无论我选择哪个单元格,它都会返回0,0.为什么是这样?

objective-c uitableview ios

0
推荐指数
1
解决办法
5065
查看次数