How do I create a file with the iOS\Cocoa Touch\Objective-C class template in Xcode - objective-c

Forgive how simple this might sound but I'm stuck and need help. I am putting In App Purchases into may first app, which is not yet released. (So I'm very new)
I have been using a tutorial by Ray Wenderlich. I have just finished starting the Master Detail Application Template. Now it says I need to create a IAPHelper class which will be my class for the IAP the step I am on says to "create a file with the iOS\Cocoa Touch\Objective-C class template". However when I open Xcode and I select new project, I don't see this option. It has Single View Application etc.. the closest thing I see is Cocoa Touch Static Library.
Can someone tell me how I "create a file with the iOS\Cocoa Touch\Objective-C class template". I'm lost, do I do it from inside the Master Application Template? Or do I use some other template name like utility or empty application or Cocoa Touch Static Library? Or do I not have this in my version of Xcode? Or am I totally coming at this the wrong way? ahhhh!lol
I have Xcode 4.3.2
I know this is probably a no-brainer for some but not for me :(
Thanks for the help :)

In the current project you are working in, right click on a file and click "New File..." or go to File>New>File and then you will probably want a Objective-c class objection under Cocoa Touch

You need to do this in the same project which you have done till now. What you are trying to do is to create new project where as the tutorial is asking you to create new file. You have to do this in the same project which you are working on. In order to do that there is an option in file menu to add a new file to project.

Related

Xcode / AppleScript / Objective-C (AppDelegate.applescript)

I am having a lot of issues following this video tutorial. I'm getting hung up on the AppDelegate.applescript file. AppleScript Facelift
Here are the steps I'm taking:
1. Create a new project
2. Then I choose "App"
3.1 Options for interface
3.2 Options for Language
Save to file location - can't attach an image due to limit
5. "Template" files created
6. I can add frameworks and libraries (not sure if this is necessary? im doing things blindly...)
7. Then these are the AppDelegate files. (note- I can change the identity and type in the top right fields. if I select AppleScript Uncompiled Source, it does not change the extension)
I've tried creating a new "blank file" and saving it as AppDelegate.applescript, but I don't think this is working. Can someone point me in the right direction???
I've been working on an AppleScript project which works with my Apple Music. Someone mentioned I should look into Objective-C AppleScript, but this is making no sense. I think my end goal is having a window that allows more flexibility with input...
Thanks in advance!
The answer: I was taking a very dated approach to this and asking the wrong question.#has's suggestion to look at his project Swift-AppleScriptObjC is exactly what I needed.

How to make a custom Class file part of Xcode? (I.E. importable from any new project without having to copy the class)

As the title says, I wanna be able to import a custom class of mine from any new project. So for example, if I have a class called LAView, I wanna be able to type #import "LAView.h" from any new project without actually having to copy LAView.h and LAView.m into the project itself. Is that possible? :)
Create a framework, copy the finished product into /Applications/Xcode.app/Contents/Developer/Library/Frameworks and /Library/Frameworks/
This way your framework will be visible and available in any Xcode project and you can access it like any other framework from the Xcode frameworks list.
NOTE: When you edit your framework you will have to copy the new version into both these locations again. You can automate this using BASH scripts run from the Terminal (if you do this be careful!).

How to intercept reading of plist values in Objective-C code?

We're using the new Urban Airship iOS plugin for PhoneGap.
In the plugin's plist file, we're supposed to enter the app-specific keys needed to enable push notifications.
The problem is we have two versions, free and paid, of the same app, but the plist file only accommodates one version.
Essentially, we need to modify the Objective-C code to read different plist values, depending on whether it's the free or premium version.
We currently manage both versions with the same code base and Xcode project. Unless we change the plugin code, it seems like we need to create a new Xcode project, which we don't want to do.
How do we adjust Urban Airship's Objective-C files to read different values from the plsit file?
Sorry to keep you waiting, I wanted to give you a very detailed answer instead of rushing last night :) So here we go.
First in your project we need to add a new target. Go to your project settings and right click your target. Click duplicate.
You'll get a new target probably named Target-copy. You'll also get a new info.plist file just for that target.
Next we're going to edit our Pro version's Built Settings. Scroll or search and find Apple LLVM compiler 4.0 Preprocessing. Add to both your Debug and Release configurations. I normally just go with the simple PRO=1. You also need to add PRO=0 to your lite version or it will be undefined when you try to build that version.
Now lets look at how to add a custom plist like I'm sure you'll need. First create two folders. Its important these are folders not groups. In each folder we can create a plist with the exact same filename.
Since Now you can add something to each of them. I just added a key property and a value pro string / lite string. Finally to the code. In the sample project I made I simple overrode viewDidLoad but obviously this will work anywhere. Since the plists have the same name you can load them with one line of code. They'll never get mixed up because they are only copied to their respective target. If you need to do code level based logic you can use the PRO preprocessor we made.
- (void)viewDidLoad
{
[super viewDidLoad];
// This will load the proper plist automatically.
NSLog(#"Plist Value: %#",[[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:#"Property List" ofType:#"plist"]] objectForKey:#"property"]);
// Also remember we set up a preprocessor PRO. you can use it as well.
if (PRO) {
NSLog(#"Only Show for Pro");
} else {
NSLog(#"Only Show for Lite");
}
NSLog(#"This will show for both");
}
This is the method I use for all my lite/pro version apps so I can share a common codebase without copying it between projects or other complicated systems. It has worked pretty well for me so far :) Happy Coding!
Source
Figured someone may be able to use the project to look at so here it is on GitHub.

How to find out what the first view controller that gets loaded in an iPhone app is?

I think that looking at others' code is a good way to learn. I'm trying to learn iOS programming like this, but one thing that's confusing is when I look at a new project there's always a bunch of view controllers, and I don't know which one loads first.
Is there an entry in the plist file which says which view controller gets loaded first? How do you go about picking apart someone else's code in an Xcode project?
In the project there's a space called Main Interface / Main Storyboard that looks like this:
Target > General > Deployment Info > Main Interface:
But if they set it in code, then use ⇧+⌘+F on the project and search for 'rootViewController'.

How can I setup a project to operate like the 'Window-Based Application' project template from XCode 4.0, in 4.2+?

I'm using XCode 4.2, and I'm struggling with how to create a Single or MultiView application from an Empty Application project.
Previously, XCode had a Window-Based Application template, and it has been removed. After a bit of Googling, I found this highly indexed article that walks through the process of creating an Empty Application project, and manually setting up like the previous Window Based application template.
The problem that I am having is that the books that I own (that aren't to old) reference the Window-Based application, and even after following the instructions on the above linked tutorial, I can't get my projects to work. I'm missing something that bridges the gap between this web tutorial and the projects that are defined in the books.
Could some one either point me to a source or give a decent, high-level walkthrough on how to define a Single-View application, starting from an Empty Application project?
The "Empty project" already creates all window stuff for you. All you need to add is a UIViewController and link it in the app delegate.
To set the UIViewController you should use -[UIWindow setRootViewController:]. The UIViewController is the only part missing from the empty project that needs to be added for the application to work.