in my app i use Yahoo Api and get responce i currently use JSONModel in this create a json JSONModel class.
Past_Match.h file Like
#import <JSONModel/JSONModel.h>
#protocol squadModel #end
#interface squadModel : JSONModel
#property (assign, nonatomic) int i;
#property (strong, nonatomic) NSString *full;
#end
#interface logoModel : JSONModel
#property (strong, nonatomic) NSString *std;
#end
#protocol teamsModel #end
#interface teamsModel : JSONModel
#property (assign, nonatomic) int i;
#property (strong, nonatomic) NSString *fn;
#property (strong, nonatomic) NSString *sn;
#property (strong, nonatomic) logoModel *logo;
#property (strong, nonatomic) NSArray<squadModel> *squad;
#end
#interface aModel : JSONModel
#property (assign, nonatomic) int i;
#property (assign, nonatomic) int r;
#property (assign, nonatomic) int o;
#property (assign, nonatomic) int w;
#property (assign, nonatomic) int cr;
#end
#interface sModel : JSONModel
#property (strong, nonatomic) aModel *a;
#end
#protocol tModel #end
#interface tModel : JSONModel
#property (assign, nonatomic) int i;
#property (assign, nonatomic) int a;
//#property (strong, nonatomic) NSString *c;
//#property (strong, nonatomic) NSString *dt;
#property (assign, nonatomic) int fd;
#property (assign, nonatomic) int bd;
//#property (strong, nonatomic) NSString *cb;
#property (assign, nonatomic) int b;
#property (assign, nonatomic) int r;
#property (assign, nonatomic) int sr;
#property (assign, nonatomic) int six;
#property (assign, nonatomic) int four;
#end
#interface anewModel : JSONModel
#property (strong, nonatomic) NSArray<tModel> *t;
#end
#interface dModel : JSONModel
#property (strong, nonatomic) anewModel *a;
#end
#protocol past_ingsModel #end
#interface past_ingsModel : JSONModel
#property (strong, nonatomic) sModel *s;
#property (strong, nonatomic) dModel *d;
#end
#interface ScorecardModel : JSONModel
#property (strong, nonatomic) NSString *mid;
#property (strong, nonatomic) NSArray<teamsModel> *teams;
#property (strong, nonatomic) NSArray<past_ingsModel> *past_ings;
#end
#interface resultsModel : JSONModel
#property (strong, nonatomic) ScorecardModel *Scorecard;
#end
#interface queryModel : JSONModel
#property (strong, nonatomic) resultsModel *results;
#end
#interface Past_Match : JSONModel
#property (strong, nonatomic) queryModel *query;
#end
Past_Match.m file Like
#import "Past_Match.h"
#implementation squadModel
#end
#implementation logoModel
#end
#implementation teamsModel
#end
#implementation aModel
#end
#implementation sModel
#end
#implementation tModel
#end
#implementation anewModel
#end
#implementation dModel
#end
#implementation past_ingsModel
#end
#implementation ScorecardModel
#end
#implementation resultsModel
#end
#implementation queryModel
#end
#implementation Past_Match
#end
in the tModel i have issue if i remove // and try to get NSString of c,dt,cd object than my Past_Match object become Null. that all 3 NSString has a same issue i can't get that value. all other value is getting. what i missing something? Thanks in Advance..
This error may occurred due to the optional values in your response object try this.... It may works
#property (strong, nonatomic)NSString<Optional> *c;
#property (strong, nonatomic) NSString<Optional> *dt;
#property (strong, nonatomic) NSString<Optional> *cb;
Tip: Please made all properties to Optional
Related
I'm using the same example on the web
OrderModel.h
#protocol ProductModel
#end
#interface ProductModel : JSONModel
#property (assign, nonatomic) int id;
#property (strong, nonatomic) NSString* name;
#property (assign, nonatomic) float price;
#end
#implementation ProductModel
#end
#interface OrderModel : JSONModel
#property (assign, nonatomic) int order_id;
#property (assign, nonatomic) float total_price;
#property (strong, nonatomic) NSArray<ProductModel>* products;
#end
#implementation OrderModel
#end
But when I build the project I face one issue "Duplicate symbols"
duplicate symbol _OBJC_CLASS_$_OrderModel
ld: 576 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1
The #implementation should be present in a .m file and the #interface in a .h file.
You should only import the .h file. Otherwise you will have multiple implementations for the same class.
ProductModel.h:
#interface ProductModel : JSONModel
#property (assign, nonatomic) int id;
#property (strong, nonatomic) NSString* name;
#property (assign, nonatomic) float price;
#end
ProductModel.m:
#import "ProductModel.h"
#implementation ProductModel
#end
OrderModel.h:
#interface OrderModel : JSONModel
#property (assign, nonatomic) int order_id;
#property (assign, nonatomic) float total_price;
#property (strong, nonatomic) NSArray<ProductModel>* products;
#end
OrderModel.m
#import "OrderModel.h"
#implementation OrderModel
#end
If you would want to use the ProductModel class in a View Controller for example just import the "ProductModel.h":
#import "ProductModel.h"
From my MCSettingsFormViewController, I want to set MatchCenterViewController's didAddNewItem BOOL property, but without making use of a segue.
I've imported MatchCenterViewController.h, which contains that property like so:
#property (assign) BOOL didAddNewItem;
However, when I try to set it like this: MatchCenterViewController.didAddNewItem = YES;, it says "property didAddNewItem not found on object of type 'MatchCenterViewController'".
I assume this is because I haven't defined what MatchCenterViewController is. If so, how can I do this property so it sets the property correctly?
edit:
MatchCenterViewController.h:
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "AsyncImageView.h"
#import "SearchViewController.h"
#import "WebViewController.h"
#import "WSCoachMarksView.h"
#import "SLExpandableTableView.h"
#interface MatchCenterViewController : UIViewController <UITableViewDataSource>
#property (strong, nonatomic) NSString *itemSearch;
#property (strong, nonatomic) NSString *itemPriority;
//#property (strong, nonatomic) IBOutlet UITextField *itemSearch;
#property (nonatomic, strong) NSArray *imageURLs;
#property (strong, nonatomic) NSString *matchingCategoryCondition;
#property (strong, nonatomic) NSString *matchingCategoryLocation;
#property (strong, nonatomic) NSNumber *matchingCategoryMaxPrice;
#property (strong, nonatomic) NSNumber *matchingCategoryMinPrice;
#property (strong, nonatomic) NSNumber *matchingCategoryId;
#property (strong, nonatomic) NSArray *matchCenterArray;
#property (strong, nonatomic) NSString *searchTerm;
#property (strong, nonatomic) NSString *itemURL;
#property (assign) NSInteger expandedSection;
#property (assign) NSInteger rowCount;
#property (assign) BOOL didAddNewItem;
#property (assign) BOOL results;
#property (strong, nonatomic) IBOutlet UIButton *editButton;
#property (weak, nonatomic) IBOutlet UIButton *moreButton;
#property (strong) NSMutableSet *expandedSections;
#end
#interface MoreButton : UIButton
#property (assign) NSInteger expandedSection;
#property (assign) NSInteger sectionIndex;
#end
MCSettingsFormViewController.h:
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <Parse/Parse.h>
#import "MatchCenterViewController.h"
#interface MCSettingsFormViewController : UIViewController
#property (strong, nonatomic) NSString *minPrice;
#property (strong, nonatomic) NSString *maxPrice;
#property (strong, nonatomic) NSString *itemCondition;
#property (strong, nonatomic) NSString *itemLocation;
#property (strong, nonatomic) NSString *searchTerm;
#property (strong, nonatomic) NSString *itemPriority;
#property (strong, nonatomic) IBOutlet UITextField *tf;
#property (strong, nonatomic) IBOutlet UITextField *tf1;
#property (strong, nonatomic) IBOutlet UITextField *tf2;
#end
You need to use an instance of MatchCenterViewController not the name of the class. Presumably, somewhere in your app there's a reference to a MatchCenterViewController object. You can either access that reference or pick a different way of letting it know about the change.
For example, if your two controllers aren't connected to each other, you could post a notification in MCSettingsFormViewController and react to it in MatchCenterViewController.
For more specific suggestions, I'd need to know how both controllers are created and presented.
When you instantiate MatchCenterViewController, you could set it as a delegate of MCSettingsFormViewController. That way, the MatchCenterViewController defines itself as the instantiated version of the class to be edited by the MatchCenterViewController.
Here is a basic tutorial for delegates: http://www.tutorialspoint.com/ios/ios_delegates.htm
So based off of your headers, it looks like either your MCSettingsFormViewController doesn't have a property of type MatchCenterViewController-- or that property is private.
In the former case, you need to add a property to your MCSettingsFormViewController with type MatchCenterViewController.
In the latter you aren't initializing your MatchCenterViewController property.
So first, make sure you have that public/private property.
Then, when you first create and show your SettingsFormViewController, set this property to your MatchCenterViewController instance. Now your SettingsForm has a reference to the proper instance you're looking for.
At this point, you can set the property on the MatchCenter
Please help !
i have got this error , the app run on simulator and on device ...
what is the reason ?
SIgameScene.h code :
#interface SIGameScene : SKScene {
BOOL gameRunning;
double gameStartedAt;
NSTimer *timer;
int lifes;
int level;
}
#property (strong, nonatomic) SKSpriteNode *background;
#property (strong, nonatomic) SKSpriteNode *spaceship;
#property (strong, nonatomic) NSMutableArray *projectilesFriendly;
#property (strong, nonatomic) NSMutableArray *projectilesEnemy;
#property (strong, nonatomic) NSMutableArray *invaders;
#property (weak, nonatomic) id <SIGameSceneDelegate, SKSceneDelegate> delegate;
- (void)startGame;
- (void)pauseGame;
- (void)stopGame;
- (void)moveSpaceshipSidewaysByAngle:(double)angleInDegrees;
#end
So I have this -
#import <UIKit/UIKit.h>
#import "RateView.h"
#interface BasicCardViewController : UIViewController<RateViewDelegate>
#property (weak, nonatomic) IBOutlet UILabel *label;
#property(copy, nonatomic)NSString *message;
#property(atomic)NSInteger rating;
#property (strong, nonatomic) IBOutlet RateView *rateView;
#property (weak, nonatomic) IBOutlet UILabel *ratingLabel;
#end
and this - in my RateView.h file.
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#class RateView;
#protocol RateViewDelegate
-(void)rateView:(RateView *)rateView ratingDidChange:(float)rating;
#end
#interface RateView : UIView
#property(strong,nonatomic)UIImage* fullSelectedStar;
#property(strong,nonatomic)UIImage* notSelectedStar;
#property(strong, nonatomic)UIImage* halfSelectedStar;
#property (assign, nonatomic)float rating;
#property(assign) BOOL editable;
#property (strong) NSMutableArray* imageViews;
#property(assign,nonatomic) int maxRating;
#property(assign) int midMargin;
#property(assign)int leftMargin;
#property (assign) CGSize minImageSize;
#property (assign) id <RateViewDelegate> delegate;
#end
But I get two errors -
1.Cannot find protocol declaration for 'TooviaRateViewDelegate'
2.Unknown type name "RateView"
I've tried to clean, and I've verified that the files are where they should be (their filepaths are to the project).
Why is this happening?
Edit - my AppDelegate.h
#import <UIKit/UIKit.h>
#import "SearchViewController.h"
#interface TooviaAppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#property NSOperationQueue *queue;
#property (strong, nonatomic) NSDictionary *userProfile;
#property (strong, nonatomic) SearchViewController *searchViewController;
- (NSOperationQueue*) getOperationQueue;
- (id)getSettings:(NSString *)keyPath;
- (void) saveCookies;
#end
There are also issues in my SearchViewController
#import <UIKit/UIKit.h>
#import "BasicCardViewController.h"
#interface SearchViewController : UIViewController
<UISearchBarDelegate, UISearchDisplayDelegate, UITableViewDataSource, UITableViewDelegate>
- (IBAction)searchButtonClicked:(UIButton *)sender;
- (IBAction)backgroundTap:(id)sender;
#property (weak, nonatomic) IBOutlet UITableView *resultTable;
#property (weak, nonatomic) IBOutlet UITextField *searchBar;
#property (strong, nonatomic) NSArray *resultsTuples;
#property (weak, nonatomic) IBOutlet UIButton *searchButton;
#property (copy, nonatomic) NSArray *controllers;
#property(strong,nonatomic)BasicCardViewController *detailController;
Delegate and data source properties are usually marked as weak for the object graph management reasons described earlier, in “Avoid Strong Reference Cycles.”
I have this Json out of ASP MVC API
I have the InvModel and the LotModel
but when I call
_InvFeed = [[InvModel alloc] initFromURLWithString:#"http://192.168.1.206/service/api/dto/inventory/1?p=Red%20Globe"
completion:^(JSONModel *model, JSONModelError *err)
{
NSLog(#"Inventory: %#", _InvFeed );
NSLog(#"Error: %#",err);
}];
I can not figure out this error:
Error: Error Domain=JSONModelErrorDomain Code=1 "Invalid JSON data:
Attempt to initialize JSONModel object using initWithDictionary:error:
but the dictionary parameter was not an 'NSDictionary'."
UserInfo=0x109075ff0 {NSLocalizedDescription=Invalid JSON data:
Attempt to initialize JSONModel object using initWithDictionary:error:
but the dictionary parameter was not an 'NSDictionary'.,
kJSONModelKeyPath=LotDTO}
and here are the JSONModels for: LotDTO
#import "JSONModel.h"
#interface InvLotModel : JSONModel
#property (assign, nonatomic) int lotid;
#property (strong, nonatomic) NSDate* expdate;
#property (strong, nonatomic) NSString* lotserial;
#property (strong, nonatomic) NSDate* lastupddate;
#property (strong, nonatomic) NSString<Optional>* providerlotserial;
#property (assign, nonatomic) NSDecimal* qtyoriginal;
#property (assign, nonatomic) NSDecimal* qtyallocated;
#property (assign, nonatomic) NSDecimal* qtyavailable;
#property (assign, nonatomic) NSDecimal* qtyonhand;
#property (strong, nonatomic) NSDate* receiptdate;
#property (strong, nonatomic) NSString* linecomment;
#property (assign, nonatomic) NSDecimal* unitcost;
#property (strong, nonatomic) NSString* warehouse;
#end
And here the Inventory Model
#import "JSONModel.h"
#import "InvLotModel.h"
#protocol InvModel #end
#interface InvModel : JSONModel
#property (assign, nonatomic) int id;
#property (strong, nonatomic) NSString* itemid;
#property (strong, nonatomic) NSString* description;
#property (strong, nonatomic) NSDate* createdate;
#property (strong, nonatomic) NSString* createuser;
#property (assign, nonatomic) float lastcost;
#property (assign, nonatomic) BOOL monitorlevel;
#property (assign, nonatomic) int minlevel;
#property (assign, nonatomic) int maxlevel;
#property (strong, nonatomic) NSString* gtin;
#property (assign, nonatomic) float weight;
#property (strong, nonatomic) NSString* uom;
#property (strong, nonatomic) NSString* sizes;
#property (strong, nonatomic) NSString* variety;
#property (strong, nonatomic) NSString <Optional>* bag;
#property (strong, nonatomic) NSString* style;
#property (strong, nonatomic) NSString* box;
#property (strong, nonatomic) NSString* label;
#property (strong, nonatomic) NSString* commodity;
#property (strong, nonatomic) InvLotModel* LotDTO;
#end
I see two problems:
1) In the InvModel class, yo have defined LotDTO as a single object, not an array.
2) In the JSON response you have posted, the syntax for LotDTO does not seem to me valid JSON. It appears to be an array of LotDTO objects, but it does not follow the syntax for JSON arrays (which you can check, for example, here).
Make sure to mark any extension property as Ignore. I faced such an issue trying to copy the model.
Please replace this
#property (strong, nonatomic) InvLotModel* LotDTO;
with this
#property (strong, nonatomic) NSArray<InvLotModel,ConvertOnDemand>* LotDTO;
As officials at JSONModel suggest to use ConvertOnDemand to convert NSArray to JSONModelArray in one of their tutorial to avoid error in implenentation.
This may help you : Click here