Is NSArrayController deprecated, what is its replacement? - ios

I found an Xcode project that uses something called an NSArrayController like this
#import <Cocoa/Cocoa.h>
#interface MyDocument : NSPersistentDocument {
IBOutlet NSArrayController *itemsArrayController;
NSArray *_sortDescriptors;
IBOutlet NSTableView *itemsTableView;
}
I was trying to use the project, which implements drag and drop, as a guide for an app I'm currently building. There's nothing in Xcode documentation when I option click on NSArrayController and I tried to create an NSArrayController property but received a warning that it doesn't exist. Was it deprecated? What has its functionality been replaced by?

NSArrayController is part of the AppKit.framework which is only available on the MacOS platform.

Related

Big Nerd Ranch UIKit import

Why is that when I follow Big Nerd Ranch 4th edition I always need to import #import <UIKit/UIKit.h> for any class that contains UIView, UIViewController, CG stuff but the code in the solutions is somehow working without it? Is there any Xcode compliance set up that can be made to make it work well with just #import <Foundation/Foundation.h> import?
For example, in 12th chapter, where they create TouchTracker app, their code is working just fine with:
#import <Foundation/Foundation.h>
#interface BNRLine : UIView
#property (nonatomic) CGPoint begin;
#property (nonatomic) CGPoint end;
#end
However, when I copy this code to my project it does not work without additional #import <UIKit/UIKit.h> line.
They probably use .pch imports. Basically it means that before every source file it will be imported and executed. This tutorial seems like a one you could see whats going on.
They may have additional imports inside a precompiled header file with a .pch extension. You can search for this file in their project.
In Xcode, if you command-click on the import statement you can bring up the detailed list of imports and that should answer any question you may have about what is being imported.

IBOutlets not showing on XCode 6.1 (6A1052d)

This is quite a major problem: the Outlets are not appearing in IB.
To reproduce:
1) I declare a variable to be IBOutlet, for example in my view controller's .h file
#property (nonatomic, strong) IBOutlet UILabel* testlabel;
2) I open the storyboard, click on the viewcontroller.
- If this is a new project, there is no "Outlets" list.
- If this is an old project with outlets already defined, the "Outlets" list contains the previous outlets, but not the one I've added.
Has anyone had the same problem. This is really important, as I can't basically proceed unless I stop using Outlets. I can't find any info about it on the release notes.
EDIT I'm adding a video on youtube showing the problem, in case I haven't explained it properly. If I'm forgetting something obvious, I'm happy to be laughed at :) That said, I've always been following these same actions and Outlets have always been in the list.
EDIT 2 For clarity, I've removed the ivar declaration as it seemed to get most of the attention.
Outlets on Youtube
EDIT 3 Ok I seem to be hitting a problem seen previously on this question and this other question. Basically, if I open the custom class drop-down, I see only some "standard" classes, such as UIViewController. If I select any of these, I get the Outlets. For example, for UIViewController I always have that view->View. However, my project's classes are not in the drop-down. Entering the name manually seems to work, but in fact it's not. There must be some indexing issue (except I've already deleted everything from
~/Library/Developer/Xcode/DerivedData/
without success. If you wish to try, I've put my code on GitHub. This doesn't show the Outlets for me, but it does for a number of other people - so it's not a "bug" with the code strictly speaking. It's more an XCode issue. Any help would be welcome!
EDIT 4 I think here's the problem, pretty much: look on the right. The drop-down menu doesn't show the "ViewController.h" class. If I enter it manually, it seems to recognise it but in fact I suspect it doesn't. In previous times, I was always seeing the full list of my project's classes in the drop-down menu.
I've found a "solution", or workaround. Deleting the XCode data is not enough, and it's not enough to just restart it. The following sequence makes the Outlets magically re-appear and work properly:
Clean project
Close XCode
Delete all contents of ~/Library/Developer/Xcode/DerivedData/
Restart MacOs
By doing this, when you re-open XCode and it reindexes, it will show the outlets as expected.
just declare the IBOutlet like this:
#property (nonatomic, strong) IBOutlet UILabel* testlabel
Maybe a very dumb one, but have you tried Clean Project Folder, then deleting DerivedData (while Storyboard is not open), immediately quit Xcode, and opening up Xcode again, then building your project?
I ran into a similar problem, but it was due to a bug in Xcode (8.2) where Interface Builder doesn't show outlets in the Connection Inspector if those outlets have been declared with a _Nullable type annotation for Swift compatibility.
Using nullable inside #property's parentheses appears to work around the problem.
(I know the original poster's problem did not use type annotations or Xcode 8 so was slightly different, but the question summary matched my internet search so I mention this for future searchers.)

AR Location based Iphone app error

I am in the process of creating an AR based location iphone app using https://github.com/markrickert/iPhone-AR-Toolkit
I have got these errors and do not know how to fix it. Please will someone help me. With a walkthrough and correct code
Link for image http://i60.tinypic.com/2i9p8c0.png
Seems to be trivial but just check whether you have imported the .h File??
#import "ARKit.h"
"Use of undeclared identifier _arViewController". To fix that simply add a property ARViewController *arViewController; to your #interface.
#interface ScanmarksViewController() {
ARViewController *_arViewController;
}
#end
or
#interface ScanmarksViewController()
#property (strong, nonatomic) ARViewController *arViewController;
#end
Whichever you prefer.

'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named MKMapView'

I am doing a project using storyboard(first time using story board).In one of the viewcontroller there is a view with a mapview and a tableview containing prototype cells.I have included the mapkit framework and mapkit headers are imported in the corresponding viewcontroller.But i am getting this wierd error.I checked with many posts and all are pointing to the case where framework is not included.But i have included everything and still getting this issue.i cleaned and built but still this issue.any suggestions
*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named MKMapView'
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface CategoryDetailViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,MKMapViewDelegate>
#property (weak, nonatomic) IBOutlet MKMapView *mapview;
#property (weak, nonatomic) IBOutlet UITableView *tableView;
#end
Make sure that the MapKit.framework is added to your project.
To verify/add the MapKit framework to your project:
Click on your project file in the left pane, then click on Build Phases.
Open up the Link Binary with Libraries
If you do not see the MapKit.framework, you'll want to add it by clicking on the plus sign.
In Swift using a newer version of Xcode, you only need to turn this capability on in the project settings and the error will go away.
It may sound simple but in the project folder of this app the mapkit files were copied,i removed it from this folder through finder and added the mapkit again.now its working.thanks for the comment by #Craig
I saw this problem when building a WatchKit extension for iOS. In addition to the linked binary I also had to add a file to Compiled Sources.

Calling an external class in iOS

I have this class for button which was added to my project workspace. I had
linker error ( Apple Mach-o Linker Error)
Then again i opened a new project and added this class.
In my ViewController.h
#import <UIKit/UIKit.h>
#import <UIView+Glow.h>
#interface ViewController:UIViewController
#property(non atomic,strong) IBOutlet UIView *testView;
end
And in my ViewController.m
Added is the screenshot
#importViewController.h
-(void) viewDidLoad{
[super viewDidLoad];
[testView startGlowing]
}
I had
*unrecognized selector sent to instance error
This is the class
I suggest you use the Glow Category of UIView made by secret lab.
Any suggestion on how to call this class?
attached are the screenshots of the issue
If you have copied UIView+Glow.h into your project, you should use this to import it:
#import "UIView+Glow.h"
You should not use the angle brackets (<UIView+Glow.h>) to import headers that are part of your project.
If you have not copied UIView+Glow.m into your project, you need to do so.
If you have copied UIView+Glow.m into your project, you need to make sure it is included in the “Compile Sources” build phase of your target.
The easiest way to check is to open UIView+Glow.m in the primary editor. Then choose the View > Utilities > Show File Inspector menu item. Look at the File Inspector (on the right side of the Xcode window). Make sure it's showing information for UIView+Game.m. Then look at the “Target Membership” section. Make sure the checkbox next to your target is checked.
Update
The three linker errors in your final screenshot happened because you haven't added the QuartzCore framework to your project. This is the framework that contains the Core Animation classes.
If you don't know how to add a framework to your project, look at How to "add existing frameworks" in Xcode 4?.
Make sure that you use the following line at the top of the implementation file where you want to use the glow methods:
#import "UIView+Glow.h"

Resources