Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSReceiverEvaluationScriptError: 4 when I try to access an attribute of a newly created object.



Why "WithName" ? The objectSpecifier I built (and the string I see from the
reference in the result window) is based on my uuid attribute; name isn't
unique. Or is 'name' some kind of AppleScript reserved word thing?

On 7/25/07 2:45 AM, "Adam Knight" <email@hidden> wrote:

> You need a -valueInCompaniesWithName:(NSString*)name method in your
> container class that does a search and returns a single object that
> matches.  Here's what I did in Notae, for example:
> 
> - (id) valueInNotesWithName: (NSString*) theName
> {
> NSError *error;
> NSFetchRequest* fr = [[[NSFetchRequest alloc] init] autorelease];
> [fr setEntity:[NSEntityDescription entityForName:@"Note"
> inManagedObjectContext:[self managedObjectContext]]];
> [fr setPredicate:[NSPredicate predicateWithFormat:@"%@ == name",
> theName]];
> NSArray *result = [[self managedObjectContext]
> executeFetchRequest:fr error:&error];
> if (result && [result count] == 1) {
> return [result objectAtIndex:0];
> } else {
> return nil;
> }
> }
> 
> Just change Note to Company and drop it in your container class and
> you should be set.
> 
> Also, make sure the "name" attribute has the "pnam" code associated
> with it in your SDEF (and your unique ID attribute should be 'ID
> ').  Veeery important for object lookups like this.
> 
> PS: Instead of checking to make sure the count of items is one, you
> could just limit the NSFetchRequest to one item as well.  I might
> change that...
> 
> 
> Adam Knight
> "Every man is guilty of all the good he didn't do."  -- Voltaire
> 
> 
> On Jul 24, 2007, at 10:26 PM, Mike Zornek wrote:
> 
>> I'm making some progress AppleScripting my Core Data app but have a
>> issue/question.
>> 
>> I can write a command like `set newCompany to make new company` and
>> the
>> newCompany reference in the result window looks like:
>> 
>> company "FADA519A-8140-495C-8613-1ADC6CF5BA54" of application
>> "Billable"
>> 
>> However, if I try to write `name of newCompany` it fails with
>> NSReceiverEvaluationScriptError: 4. According to the documentation
>> this
>> means "The object or objects specified by the direct parameter to a
>> command
>> could not be found." When this error happens it highlights 'name'
>> so does
>> this mean it can't find the name attribute on this object or is the
>> object
>> reference just bad somehow?
>> 
>> Some commands that are working fine for me:
>> 
>> get name of company 5
>> make company with properties {name:"WWDC"}
>> delete company named "WWDC"
>> 
>> The objectSpecifier on my company class looks like this. `uuid` is
>> a custom
>> attribute i create on awakeFromInsert.
>> 
>> - (NSScriptObjectSpecifier *)objectSpecifier
>> {
>>     NSScriptClassDescription* appDesc = (NSScriptClassDescription*)
>> [NSApp
>> classDescription];
>>     return [[[NSNameSpecifier alloc]
>> initWithContainerClassDescription:appDesc containerSpecifier:nil
>> key:@"scriptingCompanies" name:[self uuid]] autorelease];
>> }
>> 
>> Any thoughts or debugging suggestions? This (AppleScript itself and
>> implementing it) is still way over my head. :-(
>> 
>> ~ Mike

~ Mike
-- 
Work: http://ClickableBliss.com
Play: http://MikeZornek.com


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/email@hidden

This email sent to email@hidden

References: 
 >Re: NSReceiverEvaluationScriptError: 4 when I try to access an attribute of a newly created object. (From: Adam Knight <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.