标签: xcode4

EXC_BAD_ACCESS 当我关闭窗口时,这也是我的应用程序的委托

EXC_BAD_ACCESS我编写了一个 Cocoa 应用程序,当我关闭应用程序窗口时出现错误。我读到这个错误通常意味着内存问题,但我已经ARC mode打开并且不需要关心释放等(xCode 禁止我调用这个函数并自动管理内存)。

错误指向return NSApplicationMain(argc, (const char **)argv);主函数中的行。

这是我的应用程序的代码:

.h 文件:

@interface MainDreamer : NSWindow <NSWindowDelegate> 
{    
    NSTextField *dreamField;
    NSTableView *dreamTable;    
    NSImageView *dreamview;

    NSMutableArray *dreamlist;  
    NSMutableArray *dataset;
}

@property (nonatomic, retain) IBOutlet NSTextField *dreamField;
@property (nonatomic, retain) IBOutlet NSTableView *dreamTable;
@property (nonatomic, retain) IBOutlet NSImageView *dreamview;
@property (nonatomic, retain) IBOutlet NSMutableArray *dreamlist;
@property (nonatomic, retain) IBOutlet NSMutableArray *dataset;
@property (assign) IBOutlet NSWindow *window;

@end
Run Code Online (Sandbox Code Playgroud)

.m 文件:

@implementation MainDreamer

@synthesize window;
@synthesize dataset;
@synthesize …
Run Code Online (Sandbox Code Playgroud)

macos cocoa exc-bad-access xcode4 automatic-ref-counting

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

在UITableView中设置复选标记

我正在尝试在UITableView(放置在弹出视图中)中选择的行中设置复选标记.其实我有这样的事情:

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    // Check if current row is selected
    Boolean isNowChecked = NO;
    if([self.tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryCheckmark) 
    {
        isNowChecked = YES;
    }

    if(isNowChecked) 
    {
        [self.tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
    }
    else 
    {
        [self.tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
    }
    return indexPath;
}
Run Code Online (Sandbox Code Playgroud)

结果我能够选择行,例如我触摸第一项然后我看到复选标记.当我向下滚动表格视图时,我看到我还检查了其他项目(编号17,22).当我取消选中我的第一个项目时,每个检查也会消失.

你有什么建议可能是这种情况的原因,我怎么能避免它?

objective-c uitableview ios xcode4 ios6

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

使用UITbaleView选择一个带有一个复选标记的特定行

Plz有人告诉我如何用一个复选标记一次选择行,而其他行不是复选标记.我试过,但在我的情况下,选中带有复选标记的多行.基本上我想用选中标记保存一行,当我选择另一行然后前一行取消选择时,此行选中带复选标记.这是我的代码

    - (NSString *)getKeyForIndex:(int)index
    {
    return [NSString stringWithFormat:@"KEY%d",index];
    }
    - (BOOL) getCheckedForIndex:(int)index
    {
     if([[[NSUserDefaults standardUserDefaults] valueForKey:[self getKeyForIndex:index]]boolValue]==YES)
     {
     return YES;
     }
     else
    {
    return NO;

       } }


- (void) checkedCellAtIndex:(int)index
    {    BOOL boolChecked = [self getCheckedForIndex:index];
        [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:!boolChecked] forKey:[self getKeyForIndex:index]];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
     {
      return List.count;
    }
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    {
      static NSString *subviewCells = @"Cells";

       UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:subviewCells];
      if (cell == nil)
     {
      cell = [[UITableViewCell alloc] …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios xcode4 xcode5

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

NSLocalizedString奇怪的警告

我正在尝试用英语和意大利语本地化我的应用程序.

我得到了这部分代码:

-(IBAction)randomSN{
int text = rand() % 2;
switch (text) {
    case 0:
        textview.text =NSLocalizedString(@"YES", @"Sì");
        break;
    case 1:
        textview.text = NSLocalizedString("@NO", @"No");
        break;
    default:
        break;
  }
}
Run Code Online (Sandbox Code Playgroud)

当我进入构建和运行时,会出现一些警告:

warning: passing argument 1 of 'localizedStringForKey:value:table:' from incompatible pointer type
Run Code Online (Sandbox Code Playgroud)

我认为它需要一张桌子才能工作或者?当它说时,警告仅在第二部分显示

            textview.text = NSLocalizedString("@NO", @"No");
Run Code Online (Sandbox Code Playgroud)

此外,当我运行项目时,模拟器设置为英语(应用程序的主要语言是意大利语),我输入的Localizable.strings没有出现.

localization objective-c ios4 xcode4

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

将String转换为Float Objective-C

我想立即检索字符串中数据的纬度和经度.为了使用它,它必须转换为浮点数,所以我可以在这里使用它而不是浮点数:

//Create a region 

mapview.mapType = MKMapTypeSatellite;
MKCoordinateRegion newRegion;
newRegion.center.latitude = 47.808435,
newRegion.center.longitude = 9.643743;
newRegion.span.latitudeDelta = 0.00472;
newRegion.span.longitudeDelta = 0.006899;

CLLocationCoordinate2D coordinate;
coordinate.latitude = 47.808435;
coordinate.longitude = 9.643743;
Run Code Online (Sandbox Code Playgroud)

我只知道如何将字符串转换为数据,但我不知道如何将其转换为浮点数.有人知道吗?

objective-c xcode4 xcode4.2

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

当我按下iPhone上的主页按钮时,我的应用程序最小化而不是关闭

当我按下主页按钮时,我的应用程序最小化而不是关闭.当我再次启动它时,应用程序启动我在其上的最后一个视图控制器,而不是返回到第一个视图控制器.这是我的故事板:

- > A - > B - > C.

当在"C"中按回家并再次启动它时,应用程序保持"C"而不是"A"

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [super dealloc];
}
- (void)viewDidUnload {
    [self setEmail:nil];
    [super viewDidUnload];
}
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c xcode4

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

如何在没有Apple开发人员包的情况下将我的iPhone应用程序部署到我的设备?

我最近购买了Xcode 4,我想知道如何将我的应用程序部署到我的设备而不会越狱或支付Apple 99美元.

iphone xcode4

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