Okay. So I have 3 .h and .m files, (2 controllers and 1 delegate) and I am somewhat new to Objective C so the instructions in dropbox have been confusing to say the least. I am coming from a Javascript background and understand the logic, but not what code to use. I tried putting the code in each combination of .h and .m files. (The controller .h and .m file then the .h and .m file for the delegate then the .h and .m file for the other controller deleting the code from the previous file before trying it on another set of files)
I am deeply confused and
.h file
#interface <controller/delegate> : NSObject {
DBRestClient *restClient;
}
.m file
- (DBRestClient*)restClient {
if (restClient == nil) {
restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
restClient.delegate = self;
}
return restClient;
}
I can only run this code in one of the classes. A controller, but I get this error:
Incompatible pointer types assigning to id
How would I fix this and is it even in the right place?
I am posting the link of dropbox Tutorial, in which you will find dropbox api and one tutorial project.It is very nicely described there.
https://www.dropbox.com/developers/reference/sdk
Below is documentation link, you just read it once.You will get clear idea.
https://www.dropbox.com/developers/start/setup#ios
Happy Coding!!!
Related
I'm noticing something really strange.
I have a class A with a property:
#interface ClassA
#property (nonatomic, strong) NSString *test;
and a synthesize in the .m file.
now if I have a second class B as following:
#import "ClassA.h"
-(void) someMethod
{
ClassA *classA = [[ClassA alloc] init];
classA.test = #"test";
}
than this works fine if the 2 class files are in the same folder.
If I however move the files to separate subfolders, it won't work anymore.
The error I get is that the property doesn't exist. Similarly, 'intellisense' won't show the test property anymore.
If I make folder groups in xcode, but leave the actual files in the same physical folder, it does work.
Whats going on here?
It can't be an include path problem, since then I wouldn't even be able to instantiate ClassA.
already tried Xcode menu "product:clean"?
and i would try to delete your app from simulator, and also Xcode:preferences:locations:derived data -> from finder delete that finder folder
Try COMMAND+SHIFT+K and
Reset content and settings in iOS Simulator.
Did you try #class ClassA?
I solved it. I had an included subproject which used a class with the exact same name.
aaaaargh...
apparently there are no errors during compilation and it's unclear which of the files it will import.
I am using the following code and getting the following errors:
EDIT: See this if you cannot read the image above!
The "ChangePasscode" is currently declared as a class and is a view controller with .h and .m files along with a .nib file.
Why are these issues happening, what can I do to fix them?
Thanks!
I'm going to say that you've not imported ChangePasscode.h in your current file.
Update: In response to comment thread below, you'll need to actually create a nav structure if you want to push view controllers. The preferred way in iOS 5 is as follows:
// AppDelegate.h
// …Other existing code
#property (nonatomic, retain) UINavigationController *navController;
#end
// AppDelegate.m
#synthesize navController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
navController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = navController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
change [NSBundle mainBundle] to nil
make sure you have import ChangePasscode.h on top of the M file
use
#class ChangePasscode;
rather than using
#import ChangePasscode.h
I am thinking this is a classic case of circular references. Maybe the two classes reference each other? Because of this forward declaration you might get all kinds of warnings when trying to reference the class name or properties of the class that has the forward declaration.
Where all have you included ChangePasscode. Also use #import rather than #include.
UPDATE: To solve your ld: duplicate symbol... error
It seems that you are compiling the same class ChangePasscode two times in different places of your code. This may happen in the following cases.
You have put the same class implementation into two different files
You actually have just one implementation of this class, however you are also linking in your project a framework or library containing a class whose name is exactly the same of yours.
You could also get this error if you mistakenly let XCode's auto-complete for #import statements specify the '.m" file for the 'duplicate' class instead of the '.h'.
Try finding in the whole project your class and make sure only one copy is available within your project.
I'm brand new to iPhone programming. I've tried some tutorials and such and now I'm trying to do a simple project to get my feet wet. And of course I have having issues getting it to do what I want. I started it by using a Navigation project. I didn't want the UITableView though I just want normal buttons that lead to the next page. Although when I tried to get rid of the UITableView I think I did it wrong so now it isn't working when I am setting up the next view.
Here is the .h (the red underline is under the MPHViewController in both places) Oh and what it wants to do is make both those UIViewController.
#import <UIKit/UIKit.h>
#import "MPHViewController.h"
#interface RootViewController : UIViewController {
MPHViewController *mphViewController;
}
#property(nonatomic,retain) MPHViewController *mphViewController;
#end
I'm thinking where I mainly messed up was in the .m (I think) I took out all the code that had to do with the UITableView and simply put this in (wasn't sure what else should be placed there).
- (UIViewController *)viewControl:(UIView *)view
{
}
Sorry for being a pain I just don't know any better way of learning how to do this other then just trial and error.
It might not be able to find the definition for your custom class.
In xcode under the project setting -> build phases, make sure the MPHViewController.m is included in the list of source files to be compiled.
Also, make sure in your MPHViewController.h that your subclassing UIViewController properly:
#interface MPHViewController : UIViewController
{
// ....
}
Make sure you synthesize it in the .m
#synthesize mphViewController;
I am writing a library to be used by developers for the iPhone (similar to the way that OpenFeint is implemented) and I am trying to create a ViewController with an associated XIB so that I can instantiate it in my code with
SplashScreenViewController *splashScreenViewController = [[SplashScreenViewController alloc] init];
UIWindow *topApplicationWindow = [self getTopWindow];
[topApplicationWindow addSubview:splashScreenViewController.view];
However, while this works with simple controls (UIButtons, etc), nothing shows up with my SplashScreenViewController. SplashScreenViewController is very simple:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#interface SplashScreenView : UIViewController {
}
#end
and the implementation is empty. In my View XIB (SplashScreenView.xib), I have tried setting the File's Owner's class to SplashScreenViewController which didn't work, then I tried it the way I've seen it done in OpenFeint which is to add a View Controller in IB and make the main UIView a child of it and make it of class SplashScreenViewController instead. That also does not work (does not display).
I'm wondering if anyone has a good idea for what I might be missing, or if someone can recommend a walkthrough for creating new ViewControllers the way that I'm attempting to.
Thanks!
Try 2 things :
Call initWithNibName not just init. Maybe the OpenFeint you were talking about were overriding the init to call initWithNibName , that's why you don't see it.
Set SplashScreenViewController as your file owner, and connect his view outlet to your
view in IB.
Hope it helps.
Instead of [splashScreenViewController alloc], try [SplashScreenViewController alloc]. I'm surprised you didn't get a compiler warning.
I am really confused - I am implementing a change to a button in several views and it works in all but 1 of them and I can't figure out what is different.
I have it declared in the .h file :
UIButton *doSomethingButton;
}
#property (nonatomic, retain) IBOutlet UIButton *doSomethingButton;
But then in the .m file I get the error 'No declaration of property 'doSomethingButton' found in the interface' in the #synthesize line and then again on the lines where it is actually used. I made sure the .m file imports the .h file. I made sure that the outlet is used correctly in Interface Builder. What else could be causing the problem?
For future reference:
I just had this happen to me. It turned out, the header (.h) file was not actually included in the project.
The tricky part is, Xcode still let me jump between counterparts and edit the file as normal, but when I tried to reveal the file in the group tree, it wasn't there.
Dragging the file back into the project from the Finder fixed the problem.
Are you sure you are doing the following in your .m file (ensure this is inside the implementation block):
#sythensize doSomethingButton
Odd; check very carefully for misspellings. I've also been occasionally burned by invisible characters ending up in the source.
Do other #property declarations work in the same pair of files?