How to sort SKProduct by Apple ID - ios

I'd like to sort those products retrieved from itunesconnect.apple.com by AppleID that are online generated automatically.
I checked SKProduct, but only find these propertis, none of which are referred to Apple ID,
#property(nonatomic, readonly) NSString *localizedDescription
#property(nonatomic, readonly) NSString *localizedTitle
#property(nonatomic, readonly) NSDecimalNumber *price
#property(nonatomic, readonly) NSLocale *priceLocale
#property(nonatomic, readonly) NSString *productIdentifier
#property(nonatomic, readonly, getter=isDownloadable) BOOL downloadable
#property(nonatomic, readonly) NSArray *downloadContentLengths
#property(nonatomic, readonly) NSString *downloadContentVersion
Does anyone know about it?

Related

Realm Error: Property requires a protocol defining the contained type

I have the following model and I'm using Realm:
#interface GUIRoutineModel : GUIModel # GUIModel is a subclass of RLMObject
#property (nonatomic, retain) NSString *dateCreated;
#property (nonatomic, retain) NSString *dateModified;
#property (nonatomic, retain) NSString *name;
#property (nonatomic, retain) NSString *type;
#property NSInteger userId;
#property int routineId; #also have same issue using NSInteger
#end
When I call:
// Persist to Realm DB
RLMRealm *realm = [RLMRealm defaultRealm];
[realm transactionWithBlock:^{
[realm addObject:routineModel];
}];
I get the following error:
'Property 'routineId' requires a protocol defining the contained type - example: NSNumber<RLMInt>.'
I have tried changing the routineId property to NSNumber<RLMint>, but that didn't work either. Can anyone tell me what I'm doing wrong?
UPDATE:
Here is another version of the model that I have tried:
#interface GUIRoutineModel : GUIModel
#property (nonatomic, retain) NSString *dateCreated;
#property (nonatomic, retain) NSString *dateModified;
#property (nonatomic, retain) NSString *name;
#property (nonatomic, retain) NSString *type;
#property NSInteger userId;
#property NSNumber<RLMInt> *routineId;
#end
The Property requires a protocol defining the contained type error is only generated by Realm for a property of type NSNumber without a protocol annotating the expected concrete type. That means it cannot be generated for either of the model classes you mention. It's likely you have a another routineId property elsewhere in your app that is triggering the error.

JSON to Object in iOS with objective-c

I have object
#interface Hourly (CoreDataProperties)
#property (nullable, nonatomic, retain) NSDate *dt;
#property (nullable, nonatomic, retain) NSNumber *temp;
#property (nullable, nonatomic, retain) NSNumber *temp_min;
#property (nullable, nonatomic, retain) NSNumber *temp_max;
#property (nullable, nonatomic, retain) NSNumber *humidity;
#property (nullable, nonatomic, retain) NSNumber *pressure;
#property (nullable, nonatomic, retain) NSString *main;
#property (nullable, nonatomic, retain) NSString *des;
#property (nullable, nonatomic, retain) NSString *icon;
#end
And url
http://api.openweathermap.org/data/2.5/forecast/dayly?lat=35&lon=139&cnt=2
I can' add json to object by jsonmodel pod because weather in list is a array .
#Ngọc Thái:
I don't really understand your question. But, if you want parse from JSON (contain array of objects) to object.
Simple, you can try it: https://github.com/elado/jastor#arrays
Hope this help!
Try my project BWJSONMatcher. It helps you easily convert a json string to NSArray:
NSArray *dataArray = [BWJSONMatcher matchJSON:YOURJSONSTRING withClass:[Hourly class]];
The library is fully opensourced and under MIT license.

How to programmatically obtain Fabric/Crashlytics framework version?

Is it possible to programmatically obtain the installed version of Crashlytics/Fabric? If so, how?
Yes; see Crashlytics.h:
#interface Crashlytics : NSObject
#property (nonatomic, readonly, copy) NSString *APIKey;
#property (nonatomic, readonly, copy) NSString *version; // !!!!!
#property (nonatomic, assign) BOOL debugMode;
...
So that would be:
NSLog(#"Using Crashlytics version %#", [[Crashlytics sharedInstance] version]);

Attribute of relationship in Core Data is returning nil when being called in iOS

I have an iOS application where I am using Core Data for storage. I have two entities ("MyEntity", and "OtherEntity") which are in a one to one relationship. Both entities are related to each other (i.e. each entity has an inverse relationship with the other). In addition to having a relationship with each other, one of the attributes of each entity is also the primarykey of the other entity.
The problem I am having is that I realize that I shouldn't have an attribute that is the foreign key of another entity, when the entities have a relationship with each other, however I am unable to retrieve the primary key indirectly by referencing the relationship attribute, but I am able to retrieve it by referencing the attribute that I explicitly set to the primary key of the other entity:
//NSInteger userId = [testUser.otherEntity.userId integerValue]; --> returns nil
NSInteger userId = [testUser.userId integerValue]; --> works fine
where "testUser" is an instance of type "MyEntity" which is a subclass of NSManagedObject, and "otherEntity" is an instance of the Entity, "OtherEntity" that has an inverse relationship with "MyEntity".
Here are the attributes of each Entity:
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#class OtherEntity;
#interface MyEntity : NSManagedObject
#property (nonatomic, strong) NSString * email;
#property (nonatomic, strong) NSNumber * primaryId; //primary key for MyEntity
#property (nonatomic, strong) NSString * metaData;
#property (nonatomic, strong) NSDate * birthDate;
#property (nonatomic, strong) NSString * name;
#property (nonatomic, strong) NSNumber * userId; //this is the primary key for OtherEntity
#property (nonatomic, strong) OtherEntity *otherEntity;
#end
and here are the attributes for OtherEntity:
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#class MyEntity;
#interface OtherEntity : NSManagedObject
#property (nonatomic, strong) NSString * address;
#property (nonatomic, strong) NSString * city;
#property (nonatomic, strong) NSString * country;
#property (nonatomic, strong) NSString * fax;
#property (nonatomic, strong) NSString * phone;
#property (nonatomic, strong) NSString * postalCode;
#property (nonatomic, strong) NSString * province;
#property (nonatomic, strong) NSNumber * myUserId//primary key of MyEntity
#property (nonatomic, strong) NSNumber * userId;//primary key of Other Entity
#property (nonatomic, strong) MyEntity *myEntity;
#end
What is it that I'm doing wrong?
(From the comments:) You did not set a relationship for testUser,
Therefore testUser.otherEntity is nil.
Then testUser.otherEntity.userId is also nil and [testUser.otherEntity.userId integerValue] return zero.

ios : how to insert null value into sqlite with fmdb

my sqlite table structure is :
CREATE TABLE "location" ("latitude" DOUBLE,"longitude" DOUBLE,"date" DATETIME,"locationDescription" VARCHAR,"photopath" VARCHAR,"placemark" BLOB,"wheelId" INTEGER,"wheelSize" DOUBLE,"frontWheelx" DOUBLE,"frontWheely" DOUBLE,"rearWheelx" DOUBLE,"rearWheely" DOUBLE)
and now I want to insert one record into the table, insert column : ( date , photopath , wheelId , wheelSize , frontWheelx , frontWheely , rearWheelx , rearWheely ) and ignore column : (latitude , longitude , locationDescription , placemark)
my code is :
BOOL succeed = [lunGaiDataBase executeUpdate:#"insert into location (date, photopath, wheelid, wheelsize, frontwheelx, frontwheely, rearwheelx, rearwheely) values(?,?,?,?,?,?,?,?)",
location.date,location.photoPath, location.wheelId,location.wheelSize,location.frontWheelx,location.frontWheely,location.rearWheelx,location.rearWheely];
my location class is :
#property (nonatomic, assign) double latitude;
#property (nonatomic, assign) double longitude;
#property (nonatomic, retain) NSDate * date;
#property (nonatomic, retain) NSString * locationDescription;
#property (nonatomic, retain) NSString * photoPath;
//#property (nonatomic, retain) NSString * category;
#property (nonatomic, retain) CLPlacemark * placemark;
#property (nonatomic, assign) NSInteger wheelId;
#property (nonatomic, assign) double frontWheelx;
#property (nonatomic, assign) double frontWheely;
#property (nonatomic, assign) double rearWheelx;
#property (nonatomic, assign) double rearWheely;
#property (nonatomic, assign) double wheelSize;
when I run the program, it crashed !! Help me !!
If i've not mistaken, your crash message would be something like "EXC_BAD_EXCESS" right?
Try this :
BOOL succeed = [lunGaiDataBase executeUpdate:#"insert into location (wheelId) values(?)",
[NSNumber numberWithInt:location.wheelId]];
Since wheelId is declared as NSInteger, you've got to pass it as
[NSNumber numberWithInt:location.wheelId]

Resources