小编Ter*_*son的帖子

无法识别的选择器发送到实例UIViewController

我一直收到错误:

NSInvalidArgumentException',原因:' - [UIViewController setPhotoCellName:]:发送到实例的无法识别的选择器

当我进入我准备segue电话时.目前我有

TabBarController-> NavigationController-> TableViewController-> TableViewController->视图控制器

上面有UI图像.

当我尝试从第二个TableView控制器转到ViewController时,会出现问题.我有从Prototype Cell到实际ViewController的segue设置.它进入了segue和崩溃.我试图将NSArray属性传递viewController给能够在其中使用URL并显示UIImage.PhotoInPlace包含我试图传递的数组.这是代码.

myTableViewControllerPhotoLocation.m代码

#import "myTableViewControllerPhotoLocation.h"
#import "FlickrImageViewController.h"

@interface myTableViewControllerPhotoLocation ()
@end

@implementation myTableViewControllerPhotoLocation
@synthesize photoInPlace = _photoInPlace; //Contains NSArray to pass


-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString:@"Photo Display"]){
        NSIndexPath* indexPath = [self.tableView indexPathForCell:sender];
        NSLog(@" Dicitonary = %@", [self.photoInPlace objectAtIndex:indexPath.row]); //Returns the picked cell
        NSLog(@"%@", [self.photoInPlace class]); //returns NSArray
        NSLog(@"%@", [self photoInPlace]); //Returns the array

        [segue.destinationViewController setPhotoCellName:[self.photoInPlace objectAtIndex:indexPath.row]]; 
        //Crashes HERE!
    }
}
Run Code Online (Sandbox Code Playgroud)

FlickrImageViewController.h代码

@property …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uitableview uiviewcontroller segue

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

MKMapView单击引脚不会调用didSelectAnnotationView

我正在使用mapView,并且当您单击地图上显示的图钉时,我正在尝试弹出标注.

引脚设置在适当的位置,所以我认为注释有效但当我点击引脚时它不会显示标注.我有show callout = YES.

didSelectAnnotationView单击引脚时,根本不会调用该方法.

是否存在一些可能导致此方法无法调用的常见问题?

objective-c mkmapview mkannotationview mkmapviewdelegate

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

核心数据使用UIManagedDocument创建的内容

我不确定coreData的结构以及如何将对象保存在目录中.所以我所知道的是你创建了一个UIManagedDocument的实例并为它创建一个URL以及它将保存文件的位置.那么你打电话给"SaveToURL",你打电话给它的确是什么?它是核心数据堆栈吗?然后,当您将信息保存到实体中时,您声明的是在实体中为每组信息在堆栈中创建的单独文件?最后,UIManagedDocument的上下文究竟是什么.

这是三个主要问题

  1. 调用"SaveToURL"时创建的是文档,文件还是堆栈?
  2. 在实体中保存信息时,是否在此文件/堆栈中创建了单独的文件?
  3. 什么是UIManagedDocument上下文?

xcode core-data objective-c nsurl uimanageddocument

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

Apple Macho Linker错误Xcode

您好我正在创建一个动态表视图,我正在尝试从存储在其他文件中的方法上传信息.当我尝试测试我是否收到信息时,我得到了Macho Linker Error

架构i386的未定义符号:"_ OBJC_CLASS _ $ _ FlickrFetcher",引自:MyTableViewController.o中的objc-class-ref ld:未找到架构i386的符号

这是我添加的代码导致了问题.

FlickerFetcher.h这有我的tableViewController调用topPlaces的方法

@interface FlickrFetcher : NSObject

+ (NSArray *)topPlaces;
+ (NSArray *)photosInPlace:(NSDictionary *)place maxResults:(int)maxResults;
+ (NSURL *)urlForPhoto:(NSDictionary *)photo format:(FlickrPhotoFormat)format;

@end
Run Code Online (Sandbox Code Playgroud)

TableViewController文件.我觉得这个问题发生在setter Brain我懒得实例化它因为代码在我添加它之前工作正常,NSlog返回NUll因为没有对象但是它正在工作,然后当我添加setter来实现它我得到了Macho Linker错误.

#import "MyTableViewController.h"
#import "FlickrFetcher.h"

@interface MyTableViewController ()
@property (nonatomic, strong) FlickrFetcher* brain;
@end

@implementation MyTableViewController
@synthesize brain= _brain;

 //Error occured after I added this setter
-(FlickrFetcher*) brain
  {
  if (!_brain) _brain= [[FlickrFetcher alloc] init];
   return _brain;
}


- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) { …
Run Code Online (Sandbox Code Playgroud)

xcode linker class mach-o objective-c

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

在块中声明变量,目标C.

线程我的项目,但使用队列和块,但我尝试排队代码时收到错误.我知道你不能在块中排列UI元素,所以我避免这样做,但我得到的错误是当我在块之外调用UI元素时它表示尽管在块内声明了变量,但是它没有声明.这是代码.代码是一个UITableView方法,它只需要一个数组对它进行排序并显示它.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Create an instance of the cell
UITableViewCell *cell;
cell = [self.tableView dequeueReusableCellWithIdentifier:@"Photo Description"];

if(!cell)
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Photo Description"];

// set properties on the cell to prepare if for displaying
//top places returns an array of NSDictionairy objects, must get object at index and then object for key

//Lets queue this
dispatch_queue_t downloadQueue = dispatch_queue_create("FlickerPhotoQueue", NULL);
dispatch_async(downloadQueue, ^{

//lets sort the array

NSArray* unsortedArray = [[NSArray alloc] initWithArray:[[self.brain class] …
Run Code Online (Sandbox Code Playgroud)

variables queue xcode block objective-c

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