Ambigious reference to member 'create' Swift and ObjectiveRecord - objective-c

I'm using ObjectiveRecord library. There's no problem when use this with Objective-C. But when I use with Swift, maybe it's new to some one, there's problem when I want to create a record to database.
I use Birdging-Header.h with code as below
#import "ObjectiveRecord.h"
When I call as below
var category:Category = Category.create()
category.pkId = 1
category.title = "This is a sample"
At the first line the is error "Ambigious reference to member 'create'".
Is there anyone experience with this error. Please give me advice! Thanks a lot !
Edited:
Detail of Category class
class Category: NSManagedObject {
var pkId: NSInteger?
var title: NSString?
var img: NSString?
}
This is Category class.
Edited:
I resolved the problem above, but now I'm facing another problem. This is how to resolve the above
let category:Category = Category.create() as! Category
Now it throw error as below
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an entity named 'Shopping.Category' in this model.'
Is there anyone know how to solve this ?

Related

What context should I give to AlertDialog.Builder?

I have a problem with AlertDialog.Builder, I am trying to find the right context to give to builder = AlertDialog.Builder(this) but I keep having this error message Type mismatch. Required: Context Found: ProfilFragment
import : androidx.appcompat.app.AlertDialog
I really don't know at this point what context to use instead.
Thank you
You can access context from a fragment by using requireContext(). So pass requireContext() instead of this in the AlertDialog.Builder

Assertion Failed: Expected the primary data returned by the serializer for a `queryRecord` response to be a single object but instead it was an array

I have just got this error a few days ago. Whenever I try to run
this.store.queryRecord('user', {filter:{username : params.username}});
It shows error: Assertion Failed: Expected the primary data returned by the serializer for a queryRecord response to be a single object but instead it was an array.
What is the problem here?
You backend should return one object not array.
Found a way to avoid this problem. Instead of queryRecord ( which seems to be changed by ember-data developer team ), I use store.query like this:
this.store.query('user', {filter:{username : params.username}}).then(function(user){return user.get('firstObject')});
I encountered similar situation , had 2 routes
this.get('/clients', function() {return {data: [allClientsDataJson]};});
this.get('/clients:id', function() {return {data: [oneClientDataJson]};});
But after using queryRecord i got same error. Thing was that second route was never called and first one was called in both causes. So instead of single result there was array with all results in second call.
After knowing only first one is always called i edited it to :
this.get('/clients', function(db, request) {
if(!Ember.isEmpty(request.queryParams)) { return oneClientDataJson
} else { return allClientsDataJson }

Which keys do I need for CNContactFormatter?

I'm trying to format a contact's name using the new CNContactFormatter. It looks like, I didn't fetch all needed name properties of the contact.
Terminating app due to uncaught exception 'CNPropertyNotFetchedException', reason: 'A property was not requested when contact was fetched.'
Does anyone know which ones are required? I tried fetching the following amongst a few others with no luck:
CNContactNamePrefixKey,
CNContactGivenNameKey,
CNContactFamilyNameKey,
CNContactMiddleNameKey,
CNContactPreviousFamilyNameKey,
CNContactNameSuffixKey,
CNContactNicknameKey,
CNContactPhoneticGivenNameKey,
CNContactPhoneticMiddleNameKey,
CNContactPhoneticFamilyNameKey,
CNContactOrganizationNameKey,
CNContactDepartmentNameKey,
CNContactJobTitleKey,
Neither the CNContactFomatter Class Reference nor the fetching method's documentation give any clue.
Thanks!
I found this in the WWDC Session 223 (starting at slide 74) and this worked for me when I was having the same problem. Use CNContactFormatter.descriptorForRequiredKeysForStyle... in the contact selection call. Example:
let contactStore = CNContactStore()
let predicate = CNContact.predicateForContactsMatchingName("John")
let foundContacts = try contactStore.unifiedContactsMatchingPredicate(predicate, keysToFetch: [CNContactFormatter.descriptorForRequiredKeysForStyle(.FullName)]
for contact in foundContacts {
print(CNContactFormatter.stringFromContact(contact, style: .FullName))
}
class func descriptorForRequiredKeys()
Use to fetch all contact keys required to create vCard data from a contact.
https://developer.apple.com/reference/contacts/cncontactvcardserialization
Example:
let containerResults = try contactStore.unifiedContacts(matching: fetchPredicate, keysToFetch:[CNContactVCardSerialization.descriptorForRequiredKeys()])

On Yii framework, getting "Unable to resolve the request'

I'm trying to modify a previous developer's app and I believe I'm mimicking previous controllers but keep getting this error. After reading up, it appears my code is correct, but obviously not. Here is my code for the file .../public_html/protected/controllers/ProcessRawDataController.php
<?php
class ProcessRawData extends Controller {
public function actionIndex()
{
echo 'bla';
exit;
}
}
?>
When I go to this URL: mydomain.com/index.php?r=processRawData/index or mydomain.com/index.php?r=processRawData i get the error. I've tried changing to all lower case as well with the same result.
After posting this question, I just realized the error. The class declaration is missing the word "Controller". It should read
class ProcessRawDataController extends Controller {

Error loading Variables stage.loaderInfo - AS3

I have a Document class that loads variables from Facebook with the use of stage.loaderInfo
var connect:FacebookConnectObject = new FacebookConnectObject( facebook, API_KEY, this.stage.loaderInfo );
But when I change the Document class (with another one responsible for the layout of my app), and try call the above from a movieclip that exists in my application with the use:
var facebook_class:FacebookAp = new FaceBppkApp
addChild(facebook_class) I get error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
I believe the error comes fro this line
this.stage.loaderInfo
since I changed the scope...
How I am supposed to fix that?
According to a post by Devonair: Seems 99 times out of a 100 when people have a problem with a 1009 error, it's because the stage property is inaccessible.
so I used this snippet
public function start() {
if
{(stage) init();}
else
{ addEventListener(Event.ADDED_TO_STAGE, init);
}
}
private function init(event:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// everything else...
}
In case sb has the same problem...