Here is my .h file:
#import <Foundation/Foundation.h>
#interface ShareOfflineItem : NSObject
#property (strong, nonatomic) id shareService;
#property (strong, nonatomic) NSString *title, *url;
#end
#interface ShareOfflineQueue : NSObject
+(ShareOfflineQueue *)sharedQueue;
-(void)addItemToQueue:(ShareOfflineItem *) item;
-(void)flushQueue;
-(void)saveQueueToDisk;
#end
As you can see nothing more special. But when I import my .h file and try to instantiate ShareOfflineItem I get a linking error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ShareOfflineItem", referenced from:
Any ideas?
Use
#class ShareOfflineItem;
#class ShareOfflineQueue;
after the import. This might help.
Related
I want to convert bellow code to objective-c code:
import Foundation
#objcMembers
final class RNBridgeInstanceHolder : NSObject {
static let sharedInstance = RNBridgeInstanceHolder()
var bridge: RCTBridge?
var rctRootView: RCTRootView?
}
I tried like this header file:
#import <Foundation/Foundation.h>
#interface RNBridgeInstanceHolder: NSObject
#property (nonatomic, strong) RCTBridge *bridge;
#property (nonatomic, strong) RCTRootView *rootView;
#end
main file below
#import <React/RCTBridge.h>
#import "RNBridgeInstanceHolder.h"
#import <React/RCTRootView.h>
#implementation RNBridgeInstanceHolder : NSObject
RCTBridge *bridge;
RCTRootView *rootView;
#end
Anyone please help me to convert this code!
I have read question after question about people getting the same error as me, but I simply do not understand them, so before you go searching for duplicate questions, maybe someone can explain to me what I am doing wrong with this subclassing deal.
I have a subclass of UIImageView called swapView that I want to subclass to override the method -(void)count for special cases. I went to subclass this as I have any pre-existing UIKit class, but when I tried to build and run the project, I get this error:
Attempting to use the forward class 'swapView' as superclass of 'coinView'
I have tried putting both the #import statement of swapView and #class swapView in coinView.h and I've tried putting the import statement in coinView.m, but it refuses to build because of this continued error. If I move the import statement into the .m file, all references to the superclass's methods and properties, such as #property (nonatomic) int max; cause errors as well.
What am I doing wrong?
swapView.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
#class ViewController;
#interface swapView : UIImageView
{
NSTimer* tmr;
}
#property (nonatomic) int current;
#property (nonatomic) int max;
#property (nonatomic, retain) UIImage* firstImage;
#property (nonatomic, retain) UIImage* secondImage;
#property (nonatomic) BOOL smallMax;
#property (nonatomic, retain) ViewController* pvc;
- (BOOL)testCollision:(CGPoint)point;
- (float)randomFloatBetween:(float)smallNumber bigNumber:(float)bigNumber;
#end
coinView.h
#import "swapView.h"
#class swapView;
#interface coinView : swapView
- (void)count;
- (void)move;
#end
For inheritance, the superclass MUST be inherited.
coinView.h
#import "swapView.h"
#interface coinView : swapView
- (void)count;
- (void)move;
#end
You're both forward declaring and importing ViewController.h in your swapView, which may cause compiler to complain.
swapView.h
#import <UIKit/UIKit.h>
#class ViewController
#interface swapView : UIImageView
.
.
.
#end
In my AppDelegate.h file i written the following code
#interface iBountyHunterAppDelegate : NSObject <UIApplicationDelegate> {
UITabBarController *tabcontroller;
}
#property (nonatomic,retain) IBOutlet UITabBarController *tabcontroller;
and in AppDelegate.h file I synthesize it.
#synthesize tabcontroller;
but in #synthesize line i get an error and the msg is: "MISSING CONTEXT FOR PROPERTY IMPLEMENTATION DECLARATION"
can anyone tell me how to solve it?
I suspect you have put the #synthesize outside of your #implementation. It should look something like this
// iBountyHunterAppDelegate.m
#import "iBountyHunterAppDelegate.h"
#implementation iBountyHunterAppDelegate
#synthesize tabcontroller; // note that this is between #implementation and #end
// other stuff
#end
"and in AppDelegate.h file I synthesize it." Probably it´s just misspelled but it has to be in .m file :P
#interface iBountyHunterAppDelegate : NSObject <UIApplicationDelegate>
{
UITabBarController IBOutlet *tabcontroller;
}
#property (nonatomic,retain) IBOutlet UITabBarController *tabcontroller;
and in AppDelegate.h file I synthesize it.
#synthesize tabcontroller;
synthesize your property in controller(iBountyHunterAppDelegate.m) file instead of interface(.h) file
I am importing File "FieldActivityViewController.h".But Showing an error
"/Users/rupeshnandha/Downloads/AQMD
Release 3/Classes/InputChoice.h:22:0
Expected specifier-qualifier-list
before 'FieldActivityViewController'
in /Users/rupeshnandha/Downloads/AQMD
Release 3/Classes/InputChoice.h"
As is a code Written in "InputChoice.h"
#import "FieldActivityViewController.h"
#protocol InputChoiceProtocol <NSObject>
#required
-(void) inputChoiceSelectedIndex :(int) index;
#end
#interface InputChoice : UIViewController {
//NSString *keyString;
FieldActivityViewController *field_act;
NSMutableArray *selectionArray;
IBOutlet UITableView *table;
NSObject<InputChoiceProtocol> *delegate;
// IBOutlet UIPickerView *picker;
}
#property (nonatomic,retain) NSArray *selectionArray;
#property (nonatomic,retain) FieldActivityViewController *field_act;
#property (nonatomic,retain) NSObject<InputChoiceProtocol> *delegate;
#end
It's not the good practice to import the application classes in .h files.
Try with forward class declaration and import you FieldActivityViewController file in .h
Use with forward class declaration #class FieldActivityViewController; at the place of your import statement.
use #class FieldActivityViewController
Most likely cause is that you have a circular dependency. InputChoice.h imports FieldActivityViewController.h and FieldActivityViewController.h imports InputChoice.h (not necessarily directly).
The best solution is to move the imports out of the header file into the .m file and put
#class FieldActivityViewController;
in InputChoice.h and
#class InputChoice
in FieldActivityViewController.h (or whichever header has InputChoic.h in it.
One of my app worked and crashed at thread0, step 35, mem address 0x00002c60
35 MyAppName 0x00002c60 0x1000 + 7264
So I called command atos to locate the crash point as below:
atos -arch armv6 -o MyAppName.app/MyAppName 0x00002c60
it returns
-[AppDelegate setGPictureArray1:] (in MyAppName) (AppDelegate.m:9)
I show all codes before the line
//AppDelegate.h
#import <UIKit/UIKit.h>
#import "RootViewController.h"
#class RootViewController;
#interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
IBOutlet RootViewController *rootViewController;
NSMutableArray * gPictureArray1;
NSMutableArray * gPictureArray2;
}
#property (nonatomic, retain) NSMutableArray * gPictureArray1;
#property (nonatomic, retain) NSMutableArray * gPictureArray2;
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) RootViewController *rootViewController;
#end
//AppDelegate.m
#import "AppDelegate.h"
#import "RootViewController.h"
#implementation AppDelegate
#synthesize window;
#synthesize rootViewController;
#synthesize gPictureArray1;//**it looks like the crash happens here**
#synthesize gPictureArray2;
I can find there is any problem.
Welcome any comment.
I would guess that either the value you are trying to set that property as is an invalid pointer (pointing to a deallocated instance) or that the existing value is invalid.
Create the following function in the implementation file and put a breakpoint in it so you can track who is calling the setter:
-(void)setGPictureArray1:(NSMutableArray*)array
{
[gPictureArray1 release];
gPictureArray1 = array;
[gPictureArray1 retain];
}
Each time it is called check the value of "array" and "gPictureArray1" to make sure it is pointing to something valid. If it is called too many times you can also use NSZombies:
http://www.cocoadev.com/index.pl?NSZombieEnabled