converting coredata files

2013-02-02 Thread Amy Heavey
Hi,

I've got an app that I write for myself (I am the only user). I made a mistake 
when creating the datamodel in xcode 3 (targeting 10.5), I used description 
as an attribute name. I have now upgraded and the current xcodes do not like 
the project file at all. 

I've got quite a lot of data in this app that I really don't want to loose. It 
uses an sql store.

Somehow I need to create a new app for 10.8 that will use the old file, or find 
a way to convert the old file to work with a new app. The new app will be 
almost the same but only have the current datamodel.

Can I create an intermediate datamodel in xcode 3 that removes the error from 
the file, and create an app. Open the file with this version to upgrade it to 
the current datamodel. Then create an xcode project without the old datamodels 
and use that?

Does this make sense?

Many Thanks,

Amy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Image Colours

2012-03-03 Thread Amy Heavey

Hi,

I've got an app that is a custom app for me and my home business, it's  
not something commercial. It's a core data app and some of the  
entities have images associated with them. The images themselves are  
stored separately, and the coredata datastore stores the reference to  
them.


What I'd like to do if its possible is to analyse the images to find  
the most dominant colours, then find images with similar colours in  
them.


I thought I would do this by analysing each image as it is saved and  
calculate the most common pixel colours, probably by analysing each  
pixel in the image? and saving the most common colours, perhaps 10  
colours. Then I can see what other images have the same colour(s) in.


Does this sound possible at all? I'm a self taught hobby programmer,  
not an expert at all.


I appreciate any advice or pointers,

Many Thanks,

Amy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Image Colours

2012-03-03 Thread Amy Heavey
Thanks everyone for your help, it has certainly given me ideas.

The images I'll be using are mainly generated web ready images, which I think 
will make it easier than photos.

I also don't need exact matches, so reducing the colour resolution would 
probably be a good idea, or perhaps if I use hsb values I could just look at 
the hue as this is the more useful value. I'll be looking for images that 
coordinate together so different shades etc of the same hue would want to be 
looked at as well.

I'll 'just' need to work out how to convert the rgb images to hsb,

Thank You all,

On 3 Mar 2012, at 20:35, Jens Alfke j...@mooseyard.com wrote:

 
 On Mar 3, 2012, at 5:17 AM, Amy Heavey wrote:
 
 I thought I would do this by analysing each image as it is saved and 
 calculate the most common pixel colours, probably by analysing each pixel in 
 the image? and saving the most common colours, perhaps 10 colours. Then I 
 can see what other images have the same colour(s) in.
 
 The trouble is that images tend to have subtle gradations of color, and even 
 an area that looks solid often has adjoining pixels that are almost but not 
 quite the same color. So you have to use approximations or averaging.
 
 I haven’t done this myself, but one approach that might work is to lower the 
 color resolution. Say you divide the raw pixel components by 16 so they’re 
 only in the range 0…15 instead of 0…255. That way nearby colors will clump 
 together into the same value. It also gives you only 4096 possible color 
 values to count occurrences of, instead of 24 million.
 
 It probably also makes a difference what color space you use. My hunch is 
 that HSB or HSV will work better than RGB. Experiment!
 
 —Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Frameworks (ConnectionKit)

2011-08-09 Thread Amy Heavey

Hi,

I'd  like to be able to use my mac app to upload an image to a server.  
From googling it seems the best way to achieve this is using the  
ConnectionKit framework to upload it via FTP.


I've downloaded the framework, but Im at a loss, the examples  
included don't build, and looking at the hillegass book there should  
be a .framework file for me to link to but I can't find one. I also  
can't find any documentation about how to use this. Can anyone point  
me in the right direction? Either for using ConnectionKit or how else  
to simply ftp a file to a server?


Many Thanks

Amy Heavey
Willow Tree Crafts
www.willowtreecrafts.co.uk



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: selected image in webview

2011-07-05 Thread Amy Heavey

Thanks,

It is for Mac OS (coredata app), but all the documentation seems to  
refer to Javascript?


I've got a webView *manWeb, and I use this to set the initial page to  
display;


	NSString *manWebString = [[Manufacturers selection]  
valueForKey:@manufacturerNewWeb];
	[[manWeb mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL  
URLWithString:manWebString]]];


Then I navigate through the pages by clicking on the links on the  
pages etc. This isn't meant to be a full browser experience, I just  
want to access my suppliers sites for quick reference.


I'm still struggling to find a way to select an image within the page.  
I'd like to simply click on an image within the webview, then a button  
in my UI to process it. I'll basically be downloading it, and saving  
the details to my app. Then I have more relationships to set etc, but  
I just can't work out how to know what image has been selected?


I'd appreciate any help,

Many Thanks

Amy



On 5 Jul 2011, at 5:07PM, Jens Alfke wrote:



On Jul 4, 2011, at 10:55 PM, Amy Heavey wrote:


Is there a way to get the selected item in a webview?
I've got a webview in my app, and I'd like to select an image and  
download it.


On Mac OS you can use the DOM APIs. On iOS I think you have to run  
JavaScript on the page — I don’t remember the exact method name, but  
there’s a method you pass a string containing JavaScript and it  
evaluates it.


—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


selected image in webview

2011-07-04 Thread Amy Heavey

Hi,

Is there a way to get the selected item in a webview?

I've got a webview in my app, and I'd like to select an image and  
download it.


Many Thanks

Amy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


attribute is an array?

2011-06-21 Thread Amy Heavey

Hi,

I'm trying to acccess a decimal attribute of an entity, and I can't  
work out why it's not working. I'm using the code below;


NSString *price = [[product valueForKey:@kitFee] stringValue];

and I get this error:

2011-06-21 12:43:34.666 ishop[30901:10b] *** -[NSCFArray stringValue]:  
unrecognized selector sent to instance 0xe74f030


kitFee is a decimal attribute, and I can successfully get string  
attributes with this code, NSString *productName = [product  
valueForKey:@kitName];


Does the error message mean that it's getting an array for kitFee when  
it should be a value?


I've cleaned and rebuilt, and it's sticking at this line, but I just  
can't see my error?


I'd appreciate any help,

Many Thanks

Amy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


OS + iOS best practice

2011-06-03 Thread Amy Heavey
I hope this appropriate for this list, if not please accept my  
apologies.


I've got a fairly basic core data app that I've written for personal  
use on my iMac. I'd like to have an iPad version as it would be very  
useful to have whilst I was mobile. (It's basically a customer/product  
database).


Is there a best way to manage sharing the data between an OS and iOS  
version? I assume it will be possible as long as they use the same  
datamodel.


I was thinking maybe some kind of dropbox sync would be best as it  
wouldn't depend on a network connection, and I wouldn't need to use  
both the mac an iPad versions at the same time. I have absolutely no  
idea how to do this though. I know some apps have built in dropbox  
sync but I fear it may be beyond me as I haven't found a handy  
tutorial anywhere.


Can anyone point me in the right direction at all?

Many Thanks

Amy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OS + iOS best practice

2011-06-03 Thread Amy Heavey
Thanks, It's an app for just me really. I just prefer to work on a  
desktop mac when I'm in the house, and I can't carry my iMac with  
me :) I do find typing much easier on an actual keyboard. Maybe I  
should just get a keyboard for the iPad?


Many Thanks

Amy



On 3 Jun 2011, at 7:11PM, John Joyce wrote:



On Jun 3, 2011, at 1:04 PM, Amy Heavey wrote:

I hope this appropriate for this list, if not please accept my  
apologies.


I've got a fairly basic core data app that I've written for  
personal use on my iMac. I'd like to have an iPad version as it  
would be very useful to have whilst I was mobile. (It's basically a  
customer/product database).


Is there a best way to manage sharing the data between an OS and  
iOS version? I assume it will be possible as long as they use the  
same datamodel.


I was thinking maybe some kind of dropbox sync would be best as it  
wouldn't depend on a network connection, and I wouldn't need to use  
both the mac an iPad versions at the same time. I have absolutely  
no idea how to do this though. I know some apps have built in  
dropbox sync but I fear it may be beyond me as I haven't found a  
handy tutorial anywhere.


Can anyone point me in the right direction at all?

Many Thanks

Amy

If it's an app for multiple users to have the same data, you  
probably want to have a central database that client apps retrieve  
data from.

Core data isn't really a multi-cient database.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


image rotation

2011-04-29 Thread Amy Heavey

Hi,

I'm trying to generate a new image that is made up of a combination of  
other images.


As I iterate over the array holding the images I want to do is...
- place the componant image in the new canvas at a certain point  
(150,187)

- rotate the componant image by a certain value (calculated previously)

I don't mind how the image fits in the new canvas, it doesn't have to  
be completely within it.


I think I need to use NSAffineTransform?

I was using drawinrect previously for non-rotated movement.

Do I need to draw the componant image to the canvas first then rotate  
it?


The code I have at the moment is

[code]
//calc rotation
double rotation = 360 / ki;
double rotateby = rotation;

//set coordinates to x,y - 150,187 to start
float x = 150;
float y = 187;

//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;

while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage 
alloc]initWithContentsOfFile:imgPath];

//rotate image


//apply image to view
[targetImage lockFocus];


			//[img drawInRect:NSMakeRect(x,y,xb,yb)  
fromRect:NSMakeRect(150,150,0,0) operation:NSCompositeCopy fraction:1];


//set new rotation
rotation = rotation+rotateby;
[/code]

I've tried looking at some of the samples, but they seem to be cover  
rotating in place and resizing which is more complicated than I'm  
looking for. I'm expecting to effectively have the componant images  
fan out on the canvas.


If anyone could help me with the process I'd be grateful, do I have to  
create a intermediary image to make the rotated image square?


Thanks,

Amy



Many Thanks

Amy Heavey
Willow Tree Crafts
www.willowtreecrafts.co.uk



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


binding relationship to checkbox

2011-03-05 Thread Amy Heavey

Hi Everyone,

I was wondering if anyone could point me in the right direction for my  
problem?


I'm working on a core data application, and in this issue I have 2  
entities, product and category. They have a many to many relationship.


In my interface I want to have a list of all the categories with a  
checkbox column, so the checkboxes indicate if there is a relationship  
between the selected product and the category. It's along the lines of  
keywords in iPhoto, so I can set/unset the relationships using the  
checkboxes?


This sounds to me like something that should be doable with the  
'magic' of bindings, but I can't see how to do this?


I do appreciate any help anyone can offer me,

Many Thanks

Amy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


array controllers and key paths

2011-01-31 Thread Amy Heavey

Hi,

I've got 3 entities, Event, CustomerOrders and CustomerORderITems.

Events has a to many relationship (eventOrders) to CustomerOrders
CustomerOrders has a to many relationship (customerOrderItems) to  
CustomerOrderItems


I'd like to be able to list all of the CustomerOrderItems for a  
selected event in a table.


I think I need to create a new array controller (eventOrderItems) but  
how do I bind the content? I've tried various array/set key paths but  
none have worked so far. Is this possible?


I've got an array controller called eventOrders which is bound to the  
Events.selection so I thought I could bind eventOrderItems to  
eventOrders.arrangedObjects keypath customerOrderItems


If I try to bind the content set I get an error saying something like  
cannot create content set, try using content array,

Cannot create NSSet from object (
) of class NSCFArray - consider using contentArray binding instead of  
contentSet binding


 but if I try that I get another error
[_NSFaultingMutableSet 0x1a0a90  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
orderItemProduct.productTitle




Many Thanks

Amy



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


loop not running

2011-01-20 Thread Amy Heavey
I've got the following code that is almost identical to code I've got  
in another app. The other app works, this one doesn't. The only  
difference between the two is the variable names;


- (IBAction)addItemsToOrder:sender;{
NSObject *order;
order = [[Orders selectedObjects] objectAtIndex:0];

NSArray *newOrderProducts;
newOrderProducts = [Products selectedObjects];
NSEnumerator *loop = [newOrderProducts objectEnumerator];
NSObject *product;
NSLog(@Hello There!);
//for each selected product:
while ((product = [loop nextObject])) {
NSLog(@Hello There! in while loop);
//create new kitItem
NSManagedObject *newOrderItem = [NSEntityDescription

   
insertNewObjectForEntityForName:@CustomerOrderItems

   
inManagedObjectContext:managedObjectContext];

//link new product to order
[newOrderItem setValue:order forKey:@customerOrderRef];
//link new order item to product
[newOrderItem setValue:product forKey:@orderItemProduct];

}

}


When I run this in the app, I see the first Hello There but nothing  
else in the log. There is definitely a Products order array in the  
interface, and it definitely has selected objects. I have table  
columns bound to the Products array so I can see they are selected.  
I've got the following in my header file as well;


IBOutlet NSArrayController *Products;


But I just can't see why it's not going into the loop?


Many Thanks

Amy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


array contents and objects

2011-01-14 Thread Amy Heavey
I've got a core data app that has 2 entities, product and status, and  
a relationship between them.


I'll be importing and updating some of the data in the app from csv  
files supplied from an outside source. The 'status' is just given as a  
string. There are 3 options, Low Stock, Out of Stock, and In Stock.


As I import, I can create new products, and set the attributes, and I  
think I know how to set the relationship once the status is defined,  
but I need to select it first.


I'm looking for something that does something like

[status selectObjectWithValue:@Low Stock]

or do I need to loop through the array each time. It's only a few but  
seems excessive to loop through it?


Many Thanks

Amy



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Mapping model

2011-01-11 Thread Amy Heavey
I've got a data model that I want to add an attribute to (as in adding  
an attribute to an entity). The attribute is optional and can begin  
with a nil value.


I've created a mapping model and it opens the old file, but I've got  
odd behaviour.


The entity is called manufacturer and it has attributes of  
manufacturerName, manufacturerAbbr, and a relationship called  
manufacturerProducts


I'm trying to add an attribute called manufacturerNewWeb.

In my interface I have a table listing all my manufacturers, with the  
name and abbr in columns, and a section below to add new details.


Now the manufacturerName and manufacturerNewWeb seem to be the same.  
If I change one in my interface they both change.


All I have added to the interface for the new attribute is a new text  
box bound to the same manufacturers array controller.


What (probably simple) thing have I missed?

Many Thanks

Amy Heavey




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Image Resolution

2010-10-18 Thread Amy Heavey

Hi,

I've got an app that generates composite images, so it places images  
onto a single canvas and saves that as a new image. It's working fine,  
but I'm struggling with the resolutions/representations issue.


The source images are not generated by us, they are from a variety of  
surces, and are generally 200pixels + on each side, however sometimes  
they are 72 dpi, and sometimes they are 300dpi. Even if an aimage is  
450pixels square, when it is set as 300 dpi it's reduced too small  
when my app reduces it it to fit a 75pixel square area.


I know this is to do with the bitmapRepresentation, but I can't work  
out how to change it. If I was doing this in photoshop I'd be keeping  
the actual pixel count, but changing the resolution from 300 to 72 for  
these images.


Can anyone point me in the right direction?  Here's the code I'm using  
at the moment:


while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];
[targetImage lockFocus];

		[img drawInRect:NSMakeRect(x,y,75,75) fromRect:NSMakeRect(20,20,0,0)  
operation:NSCompositeCopy fraction:1];



Thanks

Amy Heavey
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


confused about floats

2010-10-08 Thread Amy Heavey
I've got two float values (x and y) that I'm using to change the  
coordinates of a drawing action that is being looped through. I can  
add a value to x and it draws the next image along, but I want to test  
the value of x and if it is out of bounds I want to reset it to zero  
and increase y, so I get a grid of images drawn.


For some reason, even though I can do
x = x+128;
and it moves the image accross, x seems to be null so I can't test  
against it, my if statement ' if (x  300){' always fails.


This must be something really simple I just can't see it this morning?  
I'd appreciate any help.


Many Thanks

Amy

Full code being used:
- (IBAction)generateKitImages:(id)sender;
{
NSObject *kit;
kit = [[kits selectedObjects] objectAtIndex:0];

	NSString* fileName = [[kit valueForKey:@kitName]  
stringByAppendingString:@.jpg];
	NSString* kitimagePath = self applicationSupportFolder]  
stringByAppendingPathComponent:@images]  
stringByAppendingPathComponent:@kit]  
stringByAppendingPathComponent:fileName];	

//NSLog(@Kit Image Path: %@, kitimagePath);
//create new image 300px square
 NSImage *targetImage;
 NSSize targetSize = NSMakeSize (300, 300);
 targetImage = [[NSImage alloc] initWithSize:targetSize];


//select all images for kit
	 NSArray* kitImages = [kit  
valueForKeyPath:@kitItems.kitItemProduct.productImage];


//set coordinates to x,y - 0,0 to start
float x = 0;
float y = 0;
//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;
while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];
//NSLog(@Image: %@,img);
//resize to 100px high
//get original size
//NSSize *origSize;
//origSize = [img size];
//calculate scale factor
//[img setScalesWhenResized: YES];
//[img setSize: NSMakeSize (100., 100.)];

//apply image to view
[targetImage lockFocus];
[img drawInRect:NSMakeRect(x,y,100,100)
  fromRect:NSMakeRect(x,y,100,100)
 operation:NSCompositeCopy
  fraction:1];

[targetImage unlockFocus];

//set new coordinates
x = x+100;

		//if coordinates are too wide, start new row - if x300, reset x to  
0 and add 100 to y

if(x  300){
x = 0;
y = y+100;
}

}
//apply kit logo to view
//apply kit date (text) to view
//save files out
//create a NSBitmapImageRep
	NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep alloc]initWithData: 
[targetImage TIFFRepresentation]];

//add the NSBitmapImage to the representation list of the target
[targetImage addRepresentation:bmpImageRep];

//get the data from the representation
NSData *data = [bmpImageRep representationUsingType: NSJPEGFileType

 properties: nil];

//write the data to a file
[data writeToFile: kitimagePath
   atomically: NO];
//link images to kit
[kit setValue:kitimagePath forKey:@kitImage];
}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Confused about floats

2010-10-05 Thread Amy Heavey
I've got two float values (x and y) that I'm using to change the  
coordinates of a drawing action that is being looped through. I can  
add a value to x and it draws the next image along, but I want to test  
the value of x and if it is out of bounds I want to reset it to zero  
and increase y, so I get a grid of images drawn.


For some reason, even though I can do
x = x+128;
and it moves the image accross, x seems to be null so I can't test  
against it, my if statement ' if (x  300){' always fails.


This must be something really simple I just can't see it this morning?  
I'd appreciate any help.


Many Thanks

Amy

Full code being used:

//select all images for kit
	 NSArray* kitImages = [kit  
valueForKeyPath:@kitItems.kitItemProduct.productImage];


//set coordinates to x,y - 0,0 to start
float x = 0;
float y = 0;
//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;
while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];

//apply image to view
[targetImage lockFocus];
[img drawInRect:NSMakeRect(x,y,100,100)
  fromRect:NSMakeRect(x,y,100,100)
 operation:NSCompositeCopy
  fraction:1];

[targetImage unlockFocus];

//set new coordinates
x = x+100;

		//if coordinates are too wide, start new row - if x300, reset x to  
0 and add 100 to y

if(x  300){
x = 0;
y = y+100;
}

}

	NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep alloc]initWithData: 
[targetImage TIFFRepresentation]];


[targetImage addRepresentation:bmpImageRep];

NSData *data = [bmpImageRep representationUsingType: NSJPEGFileType

 properties: nil];
[data writeToFile: kitimagePath
   atomically: NO];
//link images to kit
[kit setValue:kitimagePath forKey:@kitImage];
}



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Confused about floats

2010-10-05 Thread Amy Heavey
Thanks for all the help everyone, I'll take a look at it all, and  
release where I need to!


Many Thanks

Amy



On 5 Oct 2010, at 4:17PM, Matt Neuburg wrote:

On Tue, 5 Oct 2010 10:17:31 +0100, Amy Heavey a...@willowtreecrafts.co.uk 


said:

  //select all images for kit
   NSArray* kitImages = [kit
valueForKeyPath:@kitItems.kitItemProduct.productImage];

  //set coordinates to x,y - 0,0 to start
  float x = 0;
  float y = 0;
  //for each image
  NSEnumerator *imageLoop = [kitImages objectEnumerator];
  NSString *imgPath;
  while ((imgPath = [imageLoop nextObject])) {


The enumerator and the call to nextObject are now unnecessary; fast
enumeration has been invented. So unless you're running on an old  
system

(of course, you might well be), you could say:

   //for each image
   for (NSString* imgPath in kitImages)



  NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];


That's a memory leak. You are saying alloc without a balancing  
release.




  //apply image to view
  [targetImage lockFocus];
  [img drawInRect:NSMakeRect(x,y,100,100)
fromRect:NSMakeRect(x,y,100,100)
   operation:NSCompositeCopy
fraction:1];


Unlikely. As soon as you add 100 to x to and y, the fromRect value  
will be
a rectangle outside the image. So it will probably be blank or black  
or
something. You probably want the fromRect to be  
NSMakeRect(0,0,100,100),
i.e. the whole of the image is to be used as the source (assuming  
that the

image is 100 by 100).




  [targetImage unlockFocus];

  //set new coordinates
  x = x+100;

  //if coordinates are too wide, start new row - if x300,  
reset x

to
0 and add 100 to y
  if(x  300){
  x = 0;
  y = y+100;
  }

  }

  NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep
alloc]initWithData:
[targetImage TIFFRepresentation]];


That's another memory leak.

m.

--
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Confused about floats

2010-10-05 Thread Amy Heavey

Got it working, Part of my issue seemed to be my logic.

300 is the bounds of my target image, and I have planned it so images  
fit inside this, so x would end up being 300. In a stupid moment, I  
set the if statement to run if x300, which initially it wouldn't be  
as it would actually equal 300. However, I didn't spot my mistake as  
the NSLog inside the if statement appeared in the debugger so I  
thought it was running the rest of the code inside the if statement. I  
changed it to  299 and voila it worked. I did also have to (is the  
term cast?) the 299 to a float.


I'm googling Fast Enumeration, but I'm compiling for 10.5,

So I'm left with the following which works as intended:

//select all images for kit
	 NSArray* kitImages = [kit  
valueForKeyPath:@kitItems.kitItemProduct.productImage];


//set coordinates to x,y - 0,0 to start
float x = 0;
float y = 75;
//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;

while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];

//apply image to view
[targetImage lockFocus];

		[img drawInRect:NSMakeRect(x,y,75,75)  
fromRect:NSMakeRect(20,20,150,150) operation:NSCompositeCopy fraction: 
1];


//set new coordinates
x = x+75;

		//if coordinates are too wide, start new row - if x300, reset x to  
0 and add 100 to y

if( x  (float)299 ){

x = x-300;
y = y+75;
NSLog(@x is greater than 300);

}

}
.
//cleanup
[bmpImageRep release];
[img release];
[kitLogoImg release];
[targetImage release];


Thanks for everyones help.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Problem with MakeKeyandOrderFront

2010-10-05 Thread Amy Heavey
My app has a secondary view that appears when I click a button (to do  
another task) it works fine most of the time. It's a core data app  
that uses an xml file store.


I've started adding data so there's now maybe 1000 instances of an  
entity in it, and I've not started adding other entities or  
relationships. My secondary view won't appear now. basically I have a  
products list that is in the first tab of a tabbed display, and then  
when I'm in the second tab the button is there to display the extra  
window with the same product list, plus other things.


Now when I click the button the focus goes from the main window but  
the second window doesn't appear. If I move the data file it works  
fine. Have I just overloaded it already? Even if all I do is open the  
app and go to the second tab and click the button, nothing?


Other than this i think I've got it doing what I want!

Thanks

Amy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem with MakeKeyandOrderFront

2010-10-05 Thread Amy Heavey

nothing in the main console app.

I only have this problem using the large data file I've created. I've  
been adding data to the app and now this just won't work. If I move  
the xml file or the app it's fine. It's fine running in xcode too.


I think I'll have to move to an sqllite store and start all over again,

Amy

On 5 Oct 2010, at 20:59, Ken Thomases wrote:


On Oct 5, 2010, at 1:55 PM, Amy Heavey wrote:

Now when I click the button the focus goes from the main window but  
the second window doesn't appear. If I move the data file it works  
fine. Have I just overloaded it already? Even if all I do is open  
the app and go to the second tab and click the button, nothing?


Check the console log (either in Xcode's console window or the main  
console log viewable with Console.app, depending on how you ran your  
app).  I bet you're getting an exception, which is just prematurely  
terminating some operation within your app.


If you're running in the debugger, enable breakpoints and Stop on  
Objective-C Exceptions in Xcode's Run menu.


Regards,
Ken



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: portable app

2010-10-02 Thread Amy Heavey

Just to let you know,

This is great, it now safely stores everything on the thumbdrive for  
easy access on any machine I like. A perfect solution.


Thank You,

Many Thanks

Amy


On 1 Oct 2010, at 12:00AM, Ariel Feinerman wrote:


Are you sure in the using of 'library/application support'? There is
of the matter is that one is designed for the app data not for the
user data.
Maybe you should save such files in a directory relative to the bundle
or in the bundle itself (not good idea). In this case you can launch
your app from your drive.

If your app is in /Users/user/yourapp, your files in
/Users/user/yourapp/Application Support, it looks:

NSString *appSupport = NSBundle mainBundle] bundlePath]
stringByDeletingLastPathComponent] stringByAppendingPathComponent:
@Appication Support];



2010/9/29 Amy Heavey a...@willowtreecrafts.co.uk


I'm writing an app for personal use, using core data.

At the moment it's set up to save the data file in the library/ 
application support/myapp folder on the machine. I also want to  
store a growing number of images to use with the app, so they are  
set to store in this folder as well.


However, I'd like to be able to use this app on my laptop as well  
as the desktop. I don't really fancy managaing some kind of sync,  
and thought the best solution would be to store the app and all the  
data/images on a thumb drive. There's only me using the app, and  
having to walk and get the drive from the office isn't a huge  
headache, and I can easily take it with me if I want to work  
elsewhere (not on my home network).


How would I set the data store to a mobile drive? can anyone point  
me at a tutorial? Is it as simple as naming the thumbdrive and  
referring to it by name in the code? The Code I've currently got is  
the auto/default type set up, following the Hillegass book as well,


Thanks,
Amy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/arielfapple%40gmail.com

This email sent to arielfap...@gmail.com




--
best regards
Ariel
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: portable app

2010-10-01 Thread Amy Heavey
This looks great, so I can store everything on the thumbdrive without  
having to set up symlinks on the machines I want to use, and I don't  
have to reference the drive itself as I can take the location from the  
app bundle, perfect. ( a bit like web relative links I suppose,)


sorry, I did mean the data etc was in the ~/library/application  
support/myapp folder.



Many Thanks

Amy



On 1 Oct 2010, at 12:00AM, Ariel Feinerman wrote:


Are you sure in the using of 'library/application support'? There is
of the matter is that one is designed for the app data not for the
user data.
Maybe you should save such files in a directory relative to the bundle
or in the bundle itself (not good idea). In this case you can launch
your app from your drive.

If your app is in /Users/user/yourapp, your files in
/Users/user/yourapp/Application Support, it looks:

NSString *appSupport = NSBundle mainBundle] bundlePath]
stringByDeletingLastPathComponent] stringByAppendingPathComponent:
@Appication Support];



2010/9/29 Amy Heavey a...@willowtreecrafts.co.uk


I'm writing an app for personal use, using core data.

At the moment it's set up to save the data file in the library/ 
application support/myapp folder on the machine. I also want to  
store a growing number of images to use with the app, so they are  
set to store in this folder as well.


However, I'd like to be able to use this app on my laptop as well  
as the desktop. I don't really fancy managaing some kind of sync,  
and thought the best solution would be to store the app and all the  
data/images on a thumb drive. There's only me using the app, and  
having to walk and get the drive from the office isn't a huge  
headache, and I can easily take it with me if I want to work  
elsewhere (not on my home network).


How would I set the data store to a mobile drive? can anyone point  
me at a tutorial? Is it as simple as naming the thumbdrive and  
referring to it by name in the code? The Code I've currently got is  
the auto/default type set up, following the Hillegass book as well,


Thanks,
Amy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/arielfapple%40gmail.com

This email sent to arielfap...@gmail.com




--
best regards
Ariel


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


portable app

2010-09-29 Thread Amy Heavey

I'm writing an app for personal use, using core data.

At the moment it's set up to save the data file in the library/ 
application support/myapp folder on the machine. I also want to store  
a growing number of images to use with the app, so they are set to  
store in this folder as well.


However, I'd like to be able to use this app on my laptop as well as  
the desktop. I don't really fancy managaing some kind of sync, and  
thought the best solution would be to store the app and all the data/ 
images on a thumb drive. There's only me using the app, and having to  
walk and get the drive from the office isn't a huge headache, and I  
can easily take it with me if I want to work elsewhere (not on my home  
network).


How would I set the data store to a mobile drive? can anyone point me  
at a tutorial? Is it as simple as naming the thumbdrive and referring  
to it by name in the code? The Code I've currently got is the auto/ 
default type set up, following the Hillegass book as well,


Thanks,
Amy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString / NSURL

2010-08-29 Thread Amy Heavey

I still get an error:

2010-08-29 09:13:46.337 ishop[2766:10b] *** -[NSURL  
URLByAppendingPathComponent:]: unrecognized selector sent to instance  
0xc6356a0
2010-08-29 09:13:46.337 ishop[2766:10b] *** -[NSURL  
URLByAppendingPathComponent:]: unrecognized selector sent to instance  
0xc6356a0


Many Thanks

Amy



On 28 Aug 2010, at 4:08PM, David Duncan wrote:


On Aug 28, 2010, at 8:04 AM, Amy Heavey wrote:


Sorry duh!

2010-08-28 15:55:27.961 ishop[1920:10b] *** -[NSURL  
stringByAppendingPathComponent:]: unrecognized selector sent to  
instance 0x16fbe0
2010-08-28 15:55:27.961 ishop[1920:10b] *** -[NSURL  
stringByAppendingPathComponent:]: unrecognized selector sent to  
instance 0x16fbe0


defaultImageLocation is an NSURL* (because thats what you created at  
the top of the method). You want to use - 
URLByAppendingPathComponent: with it.

--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString / NSURL

2010-08-29 Thread Amy Heavey

10.5 i386,

On 29 Aug 2010, at 9:21AM, Roland King wrote:


What OS are you building for?

On 29-Aug-2010, at 4:14 PM, Amy Heavey wrote:


I still get an error:

2010-08-29 09:13:46.337 ishop[2766:10b] *** -[NSURL  
URLByAppendingPathComponent:]: unrecognized selector sent to  
instance 0xc6356a0
2010-08-29 09:13:46.337 ishop[2766:10b] *** -[NSURL  
URLByAppendingPathComponent:]: unrecognized selector sent to  
instance 0xc6356a0


Many Thanks

Amy



On 28 Aug 2010, at 4:08PM, David Duncan wrote:


On Aug 28, 2010, at 8:04 AM, Amy Heavey wrote:


Sorry duh!

2010-08-28 15:55:27.961 ishop[1920:10b] *** -[NSURL  
stringByAppendingPathComponent:]: unrecognized selector sent to  
instance 0x16fbe0
2010-08-28 15:55:27.961 ishop[1920:10b] *** -[NSURL  
stringByAppendingPathComponent:]: unrecognized selector sent to  
instance 0x16fbe0


defaultImageLocation is an NSURL* (because thats what you created  
at the top of the method). You want to use - 
URLByAppendingPathComponent: with it.

--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org

This email sent to r...@rols.org


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString / NSURL

2010-08-29 Thread Amy Heavey
Thanks everyone, I've been looking at everything and still can't quite  
get my head round it, basically all I want to do is copy a selected  
file to a new location.


I'm using a coredata app, so I was trying to follow the 'default' code  
provided, but I'm compiling for 10.5 and it seems there's a bit of  
flux between string based paths and urls.


Is there sample code / tutorial somewhere I'm missing?

This is what I've got at the moment, but it's still mixing URLs and  
strings, I've tried just using strings, but the  
applicationSupportFolder returns a string, which then is immutable so  
I can't add to it?


- (IBAction)selectImageFile:(id)sender;
{
// Create the File Open Dialog class.
NSOpenPanel* openDlg = [NSOpenPanel openPanel];

// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:YES];

// process the files.
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{
// Get an array containing the full filenames of all
// files and directories selected.
NSArray* files = [openDlg filenames];

// process file
NSObject *Product;
Product = [[Products selectedObjects] objectAtIndex:0];
NSString* filePath = [files objectAtIndex:0];

NSString* fileName= [filePath lastPathComponent];
		NSURL* imagePath = [NSURL fileURLWithPath: [[self  
applicationSupportFolder] stringByAppendingPathComponent: @images]];
--Here are 2 warnings that NSURL may not respond to  
stringByAppendingPathComponent		

[imagePath stringByAppendingPathComponent:fileName];
NSLog(@Old Path is %@  New Path is %@, filePath, imagePath);
		[[ NSFileManager defaultManager ] copyItemAtPath:filePath  
toPath:imagePath error:nil];



//[Product setValue:imagePath forKey:@productImage];


}

Many Thanks

Amy



On 29 Aug 2010, at 9:30AM, Graham Cox wrote:



On 29/08/2010, at 10:14 AM, Amy Heavey wrote:


I still get an error:



On what line?

Looking at the code you have mixed string paths and URLs. Pick one  
or the other and use it consistently. While string paths are  
becoming deprecated in favour of URLs, it might be easier to just  
use string paths initially to get it working and then convert to  
URLs throughout afterwards.


For example, [NSOpenPanel filenames] is deprecated, as it returns  
the selected files as strings. Use [NSOpenPanel URLs] if you want to  
use URLs. Similarly for [NSFileManager copyItemAtPath:toPath:error]  
use [NSFileManager copyItemAtURL:toURL:error].


Mixing two different representations of a file path is what is  
causing you problems here. Be consistent.


--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString / NSURL

2010-08-29 Thread Amy Heavey

Thank You!

I had been trying to do that but couldn't get the brackets right,  
sometimes you just need to start a fresh line instead of trying to  
edit don't you.


That's working now and is perfect,

Thank you for your time and help everyone,
Many Thanks

Amy

On 29 Aug 2010, at 10:43AM, Roland King wrote:

NSFileManager copyItemAtPath:toPath: takes two NSString's so you  
can't use an NSURL anyway. In fact nothing in that code needs an  
NSURL.


Get rid of that NSURL stuff (note: typed in mail)

NSString *imagePath = [ [ [ self applicationSupportFolder ]  
stringByAppendingPathComponent:@images ]  
stringByAppendingPathComponent:fileName ];


then just use the imagePath.

On 29-Aug-2010, at 5:23 PM, Amy Heavey wrote:

Thanks everyone, I've been looking at everything and still can't  
quite get my head round it, basically all I want to do is copy a  
selected file to a new location.


I'm using a coredata app, so I was trying to follow the 'default'  
code provided, but I'm compiling for 10.5 and it seems there's a  
bit of flux between string based paths and urls.


Is there sample code / tutorial somewhere I'm missing?

This is what I've got at the moment, but it's still mixing URLs and  
strings, I've tried just using strings, but the  
applicationSupportFolder returns a string, which then is immutable  
so I can't add to it?


- (IBAction)selectImageFile:(id)sender;
{
// Create the File Open Dialog class.
NSOpenPanel* openDlg = [NSOpenPanel openPanel];

// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:YES];

// process the files.
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{
// Get an array containing the full filenames of all
// files and directories selected.
NSArray* files = [openDlg filenames];

// process file
NSObject *Product;
Product = [[Products selectedObjects] objectAtIndex:0];
NSString* filePath = [files objectAtIndex:0];

NSString* fileName= [filePath lastPathComponent];
		NSURL* imagePath = [NSURL fileURLWithPath: [[self  
applicationSupportFolder] stringByAppendingPathComponent:  
@images]];
--Here are 2 warnings that NSURL may not respond to  
stringByAppendingPathComponent		

[imagePath stringByAppendingPathComponent:fileName];
NSLog(@Old Path is %@  New Path is %@, filePath, imagePath);
		[[ NSFileManager defaultManager ] copyItemAtPath:filePath  
toPath:imagePath error:nil];



//[Product setValue:imagePath forKey:@productImage];


}

Many Thanks

Amy



On 29 Aug 2010, at 9:30AM, Graham Cox wrote:



On 29/08/2010, at 10:14 AM, Amy Heavey wrote:


I still get an error:



On what line?

Looking at the code you have mixed string paths and URLs. Pick one  
or the other and use it consistently. While string paths are  
becoming deprecated in favour of URLs, it might be easier to just  
use string paths initially to get it working and then convert to  
URLs throughout afterwards.


For example, [NSOpenPanel filenames] is deprecated, as it returns  
the selected files as strings. Use [NSOpenPanel URLs] if you want  
to use URLs. Similarly for [NSFileManager  
copyItemAtPath:toPath:error] use [NSFileManager  
copyItemAtURL:toURL:error].


Mixing two different representations of a file path is what is  
causing you problems here. Be consistent.


--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org

This email sent to r...@rols.org


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments

NSString / NSURL

2010-08-28 Thread Amy Heavey
'm trying to do a fairly simple copy file process, so I select a file,  
and it gets copied to a new location. I seem to be mixing up NSString  
and NSURL as I keep getting an NSURL error, can anyone point me down  
the right path?


This is what I've got at the moment:

- (IBAction)selectImageFile:(id)sender;
{
NSString* defaultImageLocation;
	defaultImageLocation = [NSURL fileURLWithPath: [[self  
applicationSupportFolder] stringByAppendingPathComponent: @/images/]];


// Create the File Open Dialog class.
NSOpenPanel* openDlg = [NSOpenPanel openPanel];

// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:YES];

// process the files.
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{

NSArray* files = [openDlg filenames];

// process file
NSObject *Product;
Product = [[Products selectedObjects] objectAtIndex:0];
NSString* filePath = [files objectAtIndex:0];

NSString* fileName= [filePath lastPathComponent];
NSMutableString* imagePath;
imagePath = defaultImageLocation;

[imagePath stringByAppendingPathComponent:fileName];

		[[ NSFileManager defaultManager ] copyItemAtPath:filePath  
toPath:imagePath error:nil];

[Product setValue:imagePath forKey:@productImage];


}

}

Many Thanks

Amy



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString / NSURL

2010-08-28 Thread Amy Heavey

Sorry duh!

2010-08-28 15:55:27.961 ishop[1920:10b] *** -[NSURL  
stringByAppendingPathComponent:]: unrecognized selector sent to  
instance 0x16fbe0
2010-08-28 15:55:27.961 ishop[1920:10b] *** -[NSURL  
stringByAppendingPathComponent:]: unrecognized selector sent to  
instance 0x16fbe0


Many Thanks



On 28 Aug 2010, at 4:02PM, David Duncan wrote:



On Aug 28, 2010, at 7:58 AM, Amy Heavey wrote:

'm trying to do a fairly simple copy file process, so I select a  
file, and it gets copied to a new location. I seem to be mixing up  
NSString and NSURL as I keep getting an NSURL error, can anyone  
point me down the right path?



What is the error you are getting?
--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Mapping Model

2010-08-23 Thread Amy Heavey

Hi,

I've got a core data app that I'm working on, and I started off with  
quite simple relationships. I've got a products entity, and a purchase  
order entity, which had many to m any relationships between them. I  
now need to be able to set a quantity for each product in each  
purchase order. I think I need to set up an inbetween entity, (called  
purchaseOrderItem) which stores the quantity for each product, and has  
relationships to the product and purchase order entity.


I can set it all  up in the datamodel, but to be able to use the data  
already in the app I need to migrate it over. I expect to initially  
set all quantites to 1, but I can't work out how to set up the mapping  
model so it moves the relationships correctly.


Can anyone point me in the right direction?

data model 1.0
Entities:   Product, PurchaseOrder
Relationships:  Product PurchaseOrder

data model 1.1
Entities:   Product, PurchaseOrder, PurchaseOrderItem
Relationships:  Product  PurchaseOrderItem
PurchaseOrderItem  PurchaseOrder


Many Thanks

Amy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Key Paths @count and mutablestrings

2008-11-05 Thread Amy Heavey

On 4 Nov 2008, at 17:32, Benjamin Stiglitz wrote:

PurchaseOrder is an Entity, with a relationship called products to  
the
PurchaseOrderItems Entity which lists the actual items on the  
order. I'd
like a column in my Purchase Order tabel to display the number of  
items
in the order, so I've tried a number of different things along the  
lines

of
Value: bound to Purchase Order Array Controller
arrangedObjects
@count.products

but I get the following error:
2008-11-03 18:41:44.928 powizard[8498] [NSManagedObject 0x654a70
valueForUndefinedKey:]: this class is not key value coding- 
compliant for

the key @count.
…
How do I access the count of a to-many relationship?


You’ve got that backwards; you want [EMAIL PROTECTED]


I tried this at the time and it worked, but now I've made other  
unrelated changes to the app and now it won't?


I've cleared out all my other code and associated problems, and I'm  
at the same point, key path orderReference works, but [EMAIL PROTECTED]  
doesn't?


[Session started at 2008-11-05 20:42:25 +.]
2008-11-05 20:42:28.462 powizard[22921] [_NSFaultingMutableSet  
0x165e910 addObserver:forKeyPath:options:context:] is not supported.  
Key path: @count


Thanks,

Amy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Key Paths @count and mutablestrings

2008-11-04 Thread Amy Heavey

On 4 Nov 2008, at 17:32, Benjamin Stiglitz wrote:


On Mon, Nov 03, 2008 at 06:55:24PM +, Amy Heavey wrote:


…
How do I access the count of a to-many relationship?


You’ve got that backwards; you want [EMAIL PROTECTED]


Fantastic! Thank You,



Do you mean print out on a printer, or just display on the screen?

I'll be displaying it in a view so it can be saved to PDF.


I figure I need 4 strings, 1 for each 'column' of the table I  
want, then

I can just create strings with new lines and it will lay itself out
correctly.

If I was binding a tablecolumn I would use the following binding:

arrangedObjects.qty[Purchase Order Items Array Controller
(NSArrayController)]

so how do I loop through the array, setting the string value each  
time to

create a string along the lines of @1234/n3698/n3258/n4587/n where
1234, 3698, 3258 and 4587 are the qty values?


I’m not really clear what you’re doing here. You’ll want to go through
your array controller’s arrangedObjects accessor to get the values,  
and

then pull out the keys on your own.


Is there an easy way to access the existing Array Controller from the  
code? I have a suitable Array Controller called Purchase Order Items  
Array Controller in IB, but I don't see a way to reference this in  
the code. The Array Controller is bound to the selection of another  
Array Controller.


At the moment I'm doing all the work again using a fetch request (not  
that I've got it working yet) to create an array, then looping  
through the array to pull out the data,


Ideally I'd like to be able to loop through the Purchase Order Items  
Array Controller arrangedObjects, and then set strings like


for each (object in Purchase Order Items Array Controller ){
qtyString = [[Purchase Order Items Array Controller arrangedObjects]  
valueForKey:@qty];

...
}
(where qty is an attributes of the PurchaseOrderItems Entity

but i don't think it works like that!



-Ben


Thanks for all your help though,

Amy___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Key Paths @count and mutablestrings

2008-11-03 Thread Amy Heavey

Hi,

I'm afraid I have a couple more questions :(

Key Paths Bindings
I've been quite sucessful in setting up my bindings using key paths,  
but now I'm trying to use @count.


I have a table that displays a list of PurchaseOrders.

PurchaseOrder is an Entity, with a relationship called products to  
the PurchaseOrderItems Entity which lists the actual items on the  
order. I'd like a column in my Purchase Order tabel to display the  
number of items in the order, so I've tried a number of different  
things along the lines of

Value: bound to Purchase Order Array Controller
arrangedObjects
@count.products

but I get the following error:
2008-11-03 18:41:44.928 powizard[8498] [NSManagedObject 0x654a70  
valueForUndefinedKey:]: this class is not key value coding-compliant  
for the key @count.


If I use
Value: bound to Purchase Order Array Controller
arrangedObjects
orderReference

I get the orderReference correctly. OrderReference is an attribute of  
the PurchaseOrder Entity.


How do I access the count of a to-many relationship?

Next Question...

I then want to print out some of this data, so I've created a view,  
and got it all laid out, now I just need to populate it with the  
data. I thought the easiest way would be to loop through the info and  
display strings but I'm struggling a bit.


I figure I need 4 strings, 1 for each 'column' of the table I want,  
then I can just create strings with new lines and it will lay itself  
out correctly.


If I was binding a tablecolumn I would use the following binding:

arrangedObjects.qty[Purchase Order Items Array Controller 
(NSArrayController)]


so how do I loop through the array, setting the string value each  
time to create a string along the lines of @1234/n3698/n3258/n4587/ 
n where 1234, 3698, 3258 and 4587 are the qty values?


In this case, the content set of the Purchase Order Items Array  
Controller are bound to selection.products [Purchase Order Array  
Controller]


I'd appreciate any help,

Many Thanks

Amy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: filtering a tableView from a pulldown

2008-10-30 Thread Amy Heavey

On 29 Oct 2008, at 14:42, I. Savant wrote:

On Wed, Oct 29, 2008 at 4:49 AM, Amy Heavey  
[EMAIL PROTECTED] wrote:


The pop up has selectedObject bound to Purchase Order Array  
Controller 2

selection.orderReference

...
At the moment the content Object is bound to  
selection.orderReference of the

Purchase Order Array Controller.


  Okay, but what is orderReference? Is it an attribute holding the
order number?


Yes


If so, this is at least part of your problem. You
probably want the *content values* (the strings displayed in the
popup, which represent the actual objects being listed) bound to
arrangedObjects.orderReference, but the selected *object* should
probably not be the order number. The controller key should be the
selection but the model key path should be empty. This directly
selects the purchase order object in the array controller.


If I leave the model path empty, then I get an extra line in my pop  
up with

_NSControllerObjectProxy: 0x143e450

 and it doesn't auto select the chosen Purchase ORder from the  
previous window. If I put orderReference in the model path then the  
pop up itself displays the way I intended,




  The way you have it bound now means that your Line Items
controller's content is the orderReference (which I assume is a
string, given the error you posted previously). A string probably
won't contain a list of line items, right?


correct, I think part of my problem is I am used to working with  
MySQL databases, and I'm thinking along the lines of joining across a  
value, I think I'm getting a bit confused between concepts,



I assume your PurchaseOrder
entity has a to-many relationship to the line items (we'll call it
lineItems for obvious reasons). If this is the case, then your Line
Item controller's content should be bound to the Purchase Order
controller's selection.lineItems. This means the Line Item
controller's contents points to an NS[Mutable]Set containing the line
items of the selected purchase order.


I tried to bind the contentArray to that but it threw an error,




OK, so now I tried to bind the Purchase Order Items Array Controller  
(which is your line items I believe), as follows:


content set - Purchse Order Array Controller
controller key - selection
model path - empty


  You want the content *set*. To-many relationships in Core Data deal
with NS[Mutable]Sets, not arrays. Both of these points are thoroughly
covered in the documentation, but you have to understand that you're
dealing with two separate mechanisms that happen to be designed to
work well together. This means there are two different areas of the
documentation that you need to read carefully.


Thanks, I was considering it all as Arrays, based on the fact that  
they are called Array Controllers, but an Array Controller can also  
use a Set as a datasource, (datasource not used here in the cocoa  
sense, )





But I'm still getting an error when trying to use the bindings you  
suggested above, now it doesn't like the NSSet,


[Session started at 2008-10-30 12:30:53 +.]
2008-10-30 12:30:55.531 powizard[13245] An uncaught exception was raised
2008-10-30 12:30:55.532 powizard[13245] Cannot create NSSet from  
object _NSControllerObjectProxy: 0x1646580 of class  
_NSControllerObjectProxy
2008-10-30 12:30:55.532 powizard[13245] *** Uncaught exception:  
NSInternalInconsistencyException Cannot create NSSet from object  
_NSControllerObjectProxy: 0x1646580 of class _NSControllerObjectProxy


I do appreciate all your help. I'm hoping if I can get this one  
working I'll be able to work out others myself.


Thank You

Amy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: filtering a tableView from a pulldown

2008-10-30 Thread Amy Heavey

On 30 Oct 2008, at 14:11, I. Savant wrote:

The pop up has selectedObject bound to Purchase Order Array  
Controller 2

selection.orderReference

...

At the moment the content Object is bound to  
selection.orderReference of the

Purchase Order Array Controller.


  If you're binding the content object(s), this is wrong. Again, you
want the popup's *selected object*. bound to Purchase Order Array
Controller.selection.


I did have the selected object not the content object bound.




If I leave the model path empty, then I get an extra line in my  
pop up with

_NSControllerObjectProxy: 0x143e450
 and it doesn't auto select the chosen Purchase ORder from the  
previous
window. If I put orderReference in the model path then the pop up  
itself

displays the way I intended,


  Okay, it *displays* the way you intended, but it's still designating
the orderReference string as the selected object. This is wrong. ...




  The popup can be configured in various ways (for maximum flexibility
and confusion :-)). For simplicity, how about this? Remove all popup
bindings so you're starting clean. Bind the popup's Content Values to
Purchase Order Array Controller's arrangedObjects.orderReference. Bind
the popup's Selected Value to the PO controller's
selection.orderReference.


OK, done that...


  With this set of bindings, the PO array controller's selection
management should work perfectly. This assumes the Line Item array
controller is also configured properly, so to verify your popup's
configuration, I'd disconnect the Line Item controller's content
binding for now just to test this.


OK, the pop up is displaying the PO orderReferences fine, however  
when I change the option in the pulldown, it's changing the value of  
the selected row in the table,


correct, I think part of my problem is I am used to working with  
MySQL
databases, and I'm thinking along the lines of joining across a  
value, I

think I'm getting a bit confused between concepts,


  Yeah, forget all that. It has nothing to do with Core Data because
Core Data is not an RDBMS (per the documentation). It has many
similarities but it has a number of very important differences. They
(the documentation team and developers) have coined the phrase,
object graph management and persistence framework. Take it as
gospel. Repeat after me: Core Data is NOT an RDBMS. :-)


Core Data is NOT an RDBMS :)



Thanks, I was considering it all as Arrays, based on the fact that  
they are
called Array Controllers, but an Array Controller can also use a  
Set as a

datasource, (datasource not used here in the cocoa sense, )


  Yes. Core Data was added in 10.4, the Bindings mechanism was added
in 10.3. At the time, an array controller controlled arrays (I
believe, but I may be wrong). It just wouldn't do to rename it
NSArrayAndSetController or to add another controller dedicated to
sets, but I can see the source of confusion. :-) Another important
aspect was added, too, which I'll mention in a moment.

OK, so now I tried to bind the Purchase Order Items Array  
Controller (which

is your line items I believe), as follows:
content set - Purchse Order Array Controller
controller key - selection
model path - empty

...
But I'm still getting an error when trying to use the bindings you  
suggested

above, now it doesn't like the NSSet,
2008-10-30 12:30:55.532 powizard[13245] Cannot create NSSet from  
object
_NSControllerObjectProxy: 0x1646580 of class  
_NSControllerObjectProxy

2008-10-30 12:30:55.532 powizard[13245] *** Uncaught exception:
NSInternalInconsistencyException Cannot create NSSet from object
_NSControllerObjectProxy: 0x1646580 of class  
_NSControllerObjectProxy


  Have I misspoken somewhere? I can't find where I might have, but you
quoted me saying, ... your Line
Item controller's content should be bound to the Purchase Order
controller's 'selection.lineItems'.

  I meant for your Items controller's Content Set binding to be bound
to Purchase Order Array Controller's selection.lineItems (or whatever
your to-many relationship to your items set is called). The binding
you specified above does not follow this.


OK, I think I've done that.

So now, the pulldown  filters the tableview. but there's a snag.

I select a Purchase Order in my window, and click a button which  
opens the panel with the Purchase Orders 'line items' in the table.  
The Purchase Order is in the pulldown, and the items in that order  
are in the table.


If I now select a different orderReference in the pulldown, it  
changes all of the 'lineItems' Purchase ORder to the newly selected  
one, so in my table, all of those items now have a different  
orderReference.


I expected to be able to select a different orderReference in  the  
pulldown, and for the table to update to display the lineitems for  
that OTHER order.




I do appreciate all your help. I'm hoping if I can get this one  
working I'll

be able to work out others myself.


  Been there. Once it clicks, you'll 

Re: filtering a tableView from a pulldown

2008-10-30 Thread Amy Heavey

On 30 Oct 2008, at 14:41, I. Savant wrote:


Is it possible for
you to post a pared-down version of your project somewhere for myself
and others on the list to take a look at?


I've uploaded the project folder to www.amygibbs.co.uk/xcode/powizard

one thing to note, is that at the moment the persistantstore is  
hardcoded to my thumbdrive, as if I can get it up and running I'd  
like to store the file there rather than having to copy/paste it from  
the application support folder all the time. It's not perfect but  
I've got bigger issues with this first!



Thanks,



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: filtering a tableView from a pulldown

2008-10-29 Thread Amy Heavey

On 28 Oct 2008, at 16:15, I. Savant wrote:


The pulldown is bound as follows:
content: arrangedObjects[PurchaseOrder Array Controller(NSArray  
Controller)]

content values: Purchase ORder Array Controller
arrangedObjects.orderReference


  These bindings seem fine. How about selection? One of the popup's
selection bindings should be bound to the PurchaseOrder Array
Controller's selection.


The pop up has selectedObject bound to Purchase Order Array  
Controller 2 selection.orderReference


All of this is on a panel that appears when I select a Purchase Order  
and click a Details button. The popup correctly shows the selected  
Purchase Order Order Reference, and lists all of the other Purchase  
orders within it.





The Table view has 6 columns, one of which is the Purchase Order  
number (as

displayed in the pulldown)


  This seems wrong. If your table is intended to display the line
items belonging to the order, why have the order number on each line
item?


I don't really need it, I created most of the interface by alt- 
dragging from the data model, and it put it there, at the moment it's  
handy for me to quickly see that it's not working properly, as when  
it is working, all the lines should have the same value there. It's  
not vital for it to be there though,



In any case, you need a *separate* controller to reflect the
line items of the selected order. Create an array controller and set
it up so that it holds your line item objects. We'll call it your
Line Item Array Controller.


OK, I have an Array Controller for that, called Purchase Order Items  
Array Controller.



Its contents should be bound to
PurchaseOrder Array Controller's selection.lineItems (or whatever the
key path is to your order's line items).


At the moment the content Object is bound to selection.orderReference  
of the Purchase Order Array Controller.


I tried to bind the contentArray to that but it threw an error,


  Your table view's columns should each be bound to the Line Item
Array Controller's arrangedObjects.property (where property refers
to individual properties such as item number, description,
quantity, etc.).


My Qty table column is bound to Purchase Order Items Array Controller  
arrangedObjects.qty


Then I have other columns:
Vendor SKU - Purchase Order Items Array Controller  
arrangedObjects.vendorSKU

Product -
content- Products Array Controller arrangedObjects
contentValues-Products Array Controller arrangedObjects.sku
		selectedObject-Purchase Order Items Array Controller  
arrangedObjects.product


Purchase Order (not vital) -
content- Purchase Order Array Controller arrangedObjects
		contentValues- Purchase Order Array Controller  
arrangedObjects.orderReference
		selectedObject- Purchase Order Items Array Controller  
arrangedObjects.purchaseOrder


Shipment
content- Shipment Array Controller arrangedObjects
		contentValues- Shipment Array Controller  
arrangedObjects.shipperReference
		selectedObject- Purchase Order Items Array Controller  
arrangedObjects.shipment


but the panel won't load and displays the following error:

[Session started at 2008-10-29 08:42:05 +.]
2008-10-29 08:42:07.826 powizard[6592] *** NSRunLoop ignoring  
exception '[NSCFString 0x164c740 valueForUndefinedKey:]: this class  
is not key value coding-compliant for the key qty.' that raised  
during posting of delayed perform with target 16699b0 and selector  
'invokeWithTarget:'
2008-10-29 08:42:07.829 powizard[6592] *** NSRunLoop ignoring  
exception '[NSCFString 0x164c740 valueForUndefinedKey:]: this class  
is not key value coding-compliant for the key shipment.' that raised  
during posting of delayed perform with target 1669b50 and selector  
'invokeWithTarget:'




  Spend as much time as you can manage reading over the documentation
I sent you previously. If there are things you don't understand, post
your questions back to the list for clarification.



I have read through it, and it's not as much that it doesn't make  
sense, I can see what it's saying, it's applying it that I'm  
struggling with, and I've got both the 2nd and 3rd editions of cocoa  
programming, but the second edition doesnt cover core data as much,  
and the third edition uses leopard, where I am on 10.4, and wanting  
to release for 10.4 too and the IB interface/panels etc are quite  
different,



--
I.S.


Thank you for all your help,

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


filtering a tableView from a pulldown

2008-10-28 Thread Amy Heavey
I have a pulldown button, and a tableview. They both seem to be  
displaying the correct data, but I'd like to filter the content of  
the tableview based on the selection in the pulldown button. I've  
tried all manner of binding combinations but it doesn't seem to work.


I'm a real newbie so I apologise for being a bit dim. I did try  
google, and looking at the settings in the default search box that  
alt-dragging the core data entity created, but I just can't figure it  
out.


My pulldown contains order references, and the table contains the  
items in all the orders, so when i select an order number at the top,  
I want to only display the items in that order?


Many Thanks

Amy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: filtering a tableView from a pulldown

2008-10-28 Thread Amy Heavey

I can't work out what the controllers and key paths should be.

The pulldown is bound as follows:

content: arrangedObjects[PurchaseOrder Array Controller(NSArray  
Controller)]
content values: Purchase ORder Array Controller  
arrangedObjects.orderReference


The Table view has 6 columns, one of which is the Purchase Order  
number (as displayed in the pulldown)

that column is bound as:

content: arrangedObjects[PurchaseOrder Array Controller 13(NSArray  
Controller)]

content values: arrangedObjects.orderReference

does that help at all?

I created the master/details interface by alt-dragging from the data  
model. In the model there are purchaseORderItems that have the  
following attributes/relationships:


Attributes
qty
vendorsku

Relationships
product
purchaseOrder
shipment

The tableview shows all the purchaseOrderItems, and I want to filter  
it by the order reference in the pulldown above the tableview.



Many Thanks

Amy


On 28 Oct 2008, at 14:36, I. Savant wrote:

I have a pulldown button, and a tableview. They both seem to be  
displaying
the correct data, but I'd like to filter the content of the  
tableview based
on the selection in the pulldown button. I've tried all manner of  
binding

combinations but it doesn't seem to work.


  This is difficult to answer because you left out all the critical
details (controller names, key paths, etc.). All that is left is to
point you to the documentation:

Cocoa Bindings Programming Topics - Creating a Master-Detail Interface
http://developer.apple.com/documentation/Cocoa/Conceptual/ 
CocoaBindings/Tasks/masterdetail.html


--
I.S.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Core Data adding new instance - creating relationship to existing instance

2008-09-20 Thread Amy Heavey

Thank You, and I am very sorry for being so dim,

I'm working on an app that accessing an existing file that Definitely  
has the Categories, but I'd forgotten that I'd been working on an  
empty file to make it easier to see changes I was making!



Many Thanks

Amy


On 19 Sep 2008, at 19:23, Jamie Hardt wrote:


Hi-

Your fetch request isn't finding any Categories, and the array  
returning from executeFetchRequest is empty.  Before doing the  
setValue:forKey:, you should test the returned array from  
executeFetchRequest to make sure it contains 0 categories, and  
handle the situation appropriately if it doesn't.  You should also,  
by-the-by, be passing an NSError pointer to executeFetchRequest:  
and testing that after it returns to make sure an error didn't occur.


On Sep 19, 2008, at 10:47 AM, Amy Heavey wrote:


-[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Core Data adding new instance - creating relationship to existing instance

2008-09-19 Thread Amy Heavey
I'm trying to add new instances of some entities, I've got it adding  
new objects, and I can create new relationships to new related  
objects, but I can't work out how to connect a new instance to an  
existing instance of an entity,


eg

I have items with relationship to upcs and categories. I can add the  
new item, and set all the attributes, and new relationships to the  
new upcs that are also created, but I cannot create the new  
relationship to an existing category. The Category Entity has an  
attribute called name that I want to match to an NSString


I am assuming that I would actually set the relationship in the usual  
manner:


NSManagedObject *newItem = [NSEntityDescription
insertNewObjectForEntityForName:@Item
 inManagedObjectContext:moc];



NSPredicate *catFind = [NSPredicate predicateWithFormat:@name like % 
@,categoryString];


NSFetchRequest *fetch=[[NSFetchRequest alloc] init];
		[fetch setEntity:[NSEntityDescription entityForName:@Category  
inManagedObjectContext:moc]];

[fetch setPredicate:catFind];
NSArray *category = [moc executeFetchRequest:fetch error:nil];  

[newItem setValue:[category objectAtIndex:0] forKey:@Category];

The problem is actually selecting the category, I have tried all  
manner of things, and I thought I needed a fetchRequest, but it just  
throws an error:


-[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)

because there is nothing in the array?

I'm aiming at 10.4 and using XCode 2.4.1

Can anyone help me?

Many Thanks

Amy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: referencing XML Data

2008-09-16 Thread Amy Heavey

On 14 Sep 2008, at 02:51, Nathan Kinsinger wrote:


On Sep 13, 2008, at 12:50 PM, Amy Heavey wrote:


I've got an NSXMLDocument *custdoc

but I can't work out how to actually access the data in the  
document, I've looked at NSXMLElement, NSXMLParser, NSXMLNode but  
I just can't work out the correct code.


sample xml:

sesbuddycustimport
−
customer
first_nameWillow/first_name
last_nameTree Crafts/last_name
address_199 Leggatts Way/address_1
cityHerts/city
zipWD24 5NQ/zip
countryGBR/country
user_email[EMAIL PROTECTED]/user_email
/customer
−

How can I set an NSString *firstName to the value?

I appreciate any help,

Many Thanks

Amy Heavey




If you are working with Hillegass's example he is putting the XPath  
path in the identifier of the table column and uses it in the  
tableView:objectValueForTableColumn:row: data source method. In  
your example above the path would be sesbuddycustimport/customer/ 
first_name



If you are working with the NSXMLDocument programatically then you  
need to call the nodesForXPath:error: method yourself. I would  
separate the individual customer items into an array first then you  
can get any info about any customer. Also keep in mind that  
NSXMLDocument is a subclass of NSXMLNode so you can call NSXMLNode  
methods on it.

(warning, typed into mail)

	NSArray *customerArray = [custdoc nodesForXPath:@.//customer  
error:nil];

if ([customerArray count) {
for (NSXMLNode *customerNode in customerArray) {
			NSArray *firstNameArray = [[customerNode nodesForXPath:@.// 
first_name error:nil];

if ([firstNameArray count]) {
NSString *firstNameString = [firstNameArray objectAtIndex:0]  
stringValue];

// do something with the first name string
}
// get other strings
...
// do something with the other strings
...
}
}


There are other methods of getting info out of an NSXMLDocument (or  
XML data in general), but this is how I usually approach it. You  
didn't mention what you wanted to do with the string.


Hope this helps,
--Nathan


Overall I want to extract the data from the XML file, and create new  
instances of CoreData Entities with it.


I seem to keep getting errors along the lines of NSArray / NSString /  
NSXMLNode may not respond to -nodesForXpath / stringForPath:ofNode:


It's already in a loop, and
printf( Customer: %s\n, [[obj description] cString] );

correctly print out the correct line,
Customer: customerfirst_nameWillow/first_namelast_nameTree  
Crafts/last_nameaddress_199 Leggatts Way/address_1cityHerts/ 
cityzipWD24 5NQ/zipcountryGBR/ 
countryuser_email[EMAIL PROTECTED]/user_email/customer


I just don't seem able to get the individual data,

Many Thanks
Amy___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: referencing XML Data

2008-09-16 Thread Amy Heavey
Thanks for your help Nathan, but I'm obviously doing something really  
wrong, I've got the following code,


NSArray *customerArray = [custdoc nodesForXPath:@.//customer  
error:nil];

if ([customerArray count]){
NSXMLNode *customerNode;
for (customerNode in customerArray) {
NSArray *firstNameArray;
firstNameArray = [customerNode nodesForXPath:@.//first_name  
error:nil];

if ([firstNameArray count]){
		NSString *firstNameString = [firstNameArray objectAtIndex:0]  
stringValue];

printf(First name= %s\n, firstNameString);
}
}
}


which won't build and gives the following errors:

error: parse error before 'in'
error: parse error before 'stringValue'

I had others about not accepting nested functions which is why I took  
the NSXMLNode *customerNode onto it's own line, but I can't work out  
why I can't use a for loop?


Many Thanks

Amy Heavey



On 14 Sep 2008, at 02:51, Nathan Kinsinger wrote:


On Sep 13, 2008, at 12:50 PM, Amy Heavey wrote:


I've got an NSXMLDocument *custdoc

but I can't work out how to actually access the data in the  
document, I've looked at NSXMLElement, NSXMLParser, NSXMLNode but  
I just can't work out the correct code.


sample xml:

sesbuddycustimport
−
customer
first_nameWillow/first_name
last_nameTree Crafts/last_name
address_199 Leggatts Way/address_1
cityHerts/city
zipWD24 5NQ/zip
countryGBR/country
user_email[EMAIL PROTECTED]/user_email
/customer
−
customer
first_nameL/first_name
last_nameLin/last_name
address_19/address_1
city/
zipS***/zip
countryGBR/country
user_emailla**/user_email
/customer

How can I set an NSString *firstName to the value?

I appreciate any help,

Many Thanks

Amy Heavey




If you are working with Hillegass's example he is putting the XPath  
path in the identifier of the table column and uses it in the  
tableView:objectValueForTableColumn:row: data source method. In  
your example above the path would be sesbuddycustimport/customer/ 
first_name



If you are working with the NSXMLDocument programatically then you  
need to call the nodesForXPath:error: method yourself. I would  
separate the individual customer items into an array first then you  
can get any info about any customer. Also keep in mind that  
NSXMLDocument is a subclass of NSXMLNode so you can call NSXMLNode  
methods on it.

(warning, typed into mail)

	NSArray *customerArray = [custdoc nodesForXPath:@.//customer  
error:nil];

if ([customerArray count) {
for (NSXMLNode *customerNode in customerArray) {
			NSArray *firstNameArray = [[customerNode nodesForXPath:@.// 
first_name error:nil];

if ([firstNameArray count]) {
NSString *firstNameString = [firstNameArray objectAtIndex:0]  
stringValue];

// do something with the first name string
}
// get other strings
...
// do something with the other strings
...
}
}

The .// will find all xml elements with that name at any depth in  
the node.



I do this often enough that I created a category on NSXMLNode to  
help get the string for an element:


- (NSString *)bb_StringFromXPath:(NSString *)nodePath
{
NSArray *nodeArray = [self nodesForXPath:nodePath error:nil];
	return [nodeArray count] ? [[nodeArray objectAtIndex:0]  
stringValue] : nil;

}
(Note that this will only return the string of the first xml  
element that the XPath returns, so make sure to use it on nodes  
that you know only have one such element)


So in the example above, inside the for loop I would do this:

	NSString *firstNameString = [customerNode bb_StringFromXPath:@.// 
first_name];



There are other methods of getting info out of an NSXMLDocument (or  
XML data in general), but this is how I usually approach it. You  
didn't mention what you wanted to do with the string.


Hope this helps,
--Nathan




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: referencing XML Data

2008-09-16 Thread Amy Heavey

Thanks,

I've been messing about with code all over the place, gone a little  
blind I think,


however, I now get 2 errors on this line:

1 - nested functions are disabled, use -fnested-functions to renable
2 - syntax error before in

NSArray *customerArray = [custdoc nodesForXPath:@.//customer  
error:nil];

if ([customerArray count]) {
for (NSXMLNode *customerNode in customerArray) {
		NSArray *firstNameArray = [[customerNode nodesForXPath:@.// 
first_name error:nil];

if ([firstNameArray count]) {
NSString *firstNameString = [[firstNameArray objectAtIndex:0]  
stringValue];

// do something with the first name string
NSLog(@First name = %@, firstNameString);
}
// get other strings

// do something with the other strings

}
}


Many Thanks

Amy

On 16 Sep 2008, at 19:52, Sherm Pendley wrote:



NSArray *customerArray = [custdoc nodesForXPath:@.//customer  
error:nil];

   if ([customerArray count]){
   NSXMLNode *customerNode;
   for (customerNode in customerArray) {

error: parse error before 'in'

That should be:

for (NSXMLNode *customerNode in customerArray) {


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: referencing XML Data

2008-09-16 Thread Amy Heavey

I've just tried this again, I just changed the start:

void import( NSArray *array ) {

and it is all called by:

import(custNodes);

so I beleive this line is uneccessary:
NSXMLDocument *custdoc = [[NSXMLDocument alloc] initWithData:[NSData  
dataWithContentsOfFile:@/Users/nathan/Desktop/xml testing/ 
customer.xml] options:0 error:nil];


but I still get 3 errors,

I'm using XCode 2.4.1 and wanting this to work on 10.4 systems.

I've managed to get this to nearly work:

void import( NSArray *array ) {

NSEnumerator *enumerator = [array objectEnumerator];
id obj;

while ( obj = [enumerator nextObject] ) {

//printf( Customer: %s\n, [[obj description] cString] );

		NSArray *customerArray = [custdoc nodesForXPath:@.//customer  
error:nil];

 //if ( [customerArray count]) {
//for (NSXMLNode *customerNode in customerArray){
NSLog(@First name = %@, 0);
customerNode=[custNodes objectAtIndex:0];

		NSArray *firstNameArray = [customerNode nodesForXPath:@.// 
first_name error:nil];

 //if ([firstNameArray count]) {
		NSString *firstNameString = [[firstNameArray objectAtIndex:0]  
stringValue];

NSLog(@First name = %@, firstNameString);
//}
//}
//}

}
}


but I get

2008-09-16 21:12:22.044 ag01[8400] First name = (null)
2008-09-16 21:12:22.055 ag01[8400] First name = Willow
2008-09-16 21:12:22.458 ag01[8400] First name = (null)
2008-09-16 21:12:22.469 ag01[8400] First name = Willow
2008-09-16 21:12:22.730 ag01[8400] First name = (null)
2008-09-16 21:12:22.741 ag01[8400] First name = Willow
2008-09-16 21:12:22.931 ag01[8400] First name = (null)
2008-09-16 21:12:22.937 ag01[8400] First name = Willow
2008-09-16 21:12:23.338 ag01[8400] First name = (null)
2008-09-16 21:12:23.338 ag01[8400] First name = Willow
2008-09-16 21:12:23.573 ag01[8400] First name = (null)
2008-09-16 21:12:23.587 ag01[8400] First name = Willow
2008-09-16 21:12:23.845 ag01[8400] First name = (null)
2008-09-16 21:12:23.854 ag01[8400] First name = Willow
2008-09-16 21:12:24.056 ag01[8400] First name = (null)
2008-09-16 21:12:24.064 ag01[8400] First name = Willow
2008-09-16 21:12:24.268 ag01[8400] First name = (null)


I assume it's to do with customerNode=[custNodes objectAtIndex:0];
but I can't work out what to use instead of objectAtIndex:0

Thank you for all your time,

Many Thanks

Amy

On 16 Sep 2008, at 21:02, Nathan Kinsinger wrote:



On Sep 16, 2008, at 1:24 PM, Amy Heavey wrote:


if ([firstNameArray count]) {
NSString *firstNameString = [[firstNameArray objectAtIndex:0]  
stringValue];

// do something with the first name string
NSLog(@First name = %@, firstNameString);
}
// get other strings

// do something with the other strings

}
}


Many Thanks

Amy


I don't see any problem with your for loop statement and compiling  
the code works with no errors (after fixing my syntax error). What  
version of XCode are you using?


Here's my test (written in XCode :-)

- (void)testXML 
{
	NSXMLDocument *custdoc = [[NSXMLDocument alloc] initWithData: 
[NSData dataWithContentsOfFile:@/Users/nathan/Desktop/xml testing/ 
customer.xml] options:0 error:nil];


	NSArray *customerArray = [custdoc nodesForXPath:@.//customer  
error:nil];

if ([customerArray count]) {
for (NSXMLNode *customerNode in customerArray) {
			NSArray *firstNameArray = [customerNode nodesForXPath:@.// 
first_name error:nil];

if ([firstNameArray count]) {
NSString *firstNameString = [[firstNameArray objectAtIndex:0]  
stringValue];

NSLog(@First name = %@, firstNameString);
}
}
}
}

using the data from your first email as the xml file I get:
2008-09-16 14:00:25.137 testStrings[17811:10b] First name = Willow
2008-09-16 14:00:25.159 testStrings[17811:10b] First name = L


--Nathan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


referencing XML Data

2008-09-13 Thread Amy Heavey

I've got an NSXMLDocument *custdoc

but I can't work out how to actually access the data in the document,  
I've looked at NSXMLElement, NSXMLParser, NSXMLNode but I just can't  
work out the correct code.


sample xml:

sesbuddycustimport
−
customer
first_nameWillow/first_name
last_nameTree Crafts/last_name
address_199 Leggatts Way/address_1
cityHerts/city
zipWD24 5NQ/zip
countryGBR/country
user_email[EMAIL PROTECTED]/user_email
/customer
−
customer
first_nameL/first_name
last_nameLin/last_name
address_19/address_1
city/
zipS***/zip
countryGBR/country
user_emailla**/user_email
/customer

How can I set an NSString *firstName to the value?

I appreciate any help,

Many Thanks

Amy Heavey



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: referencing XML Data

2008-09-13 Thread Amy Heavey
Thats where i got most of the code from, and I have seen the post on  
his blog,  but I still can't work it out!



Many Thanks

Amy Heavey



On 13 Sep 2008, at 20:09, Hal Mueller wrote:

The Amazone example in the new edition of the Hillegass book is a  
good place to start.  He's also got a version of this on his blog  
that covers a technique that will work on the iPhone.

http://weblog.bignerdranch.com/?p=48

Hal



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


creating new instance of coredata entity

2008-09-11 Thread Amy Heavey

Hi,

Sorry for the newbie question,

I'm trying to write an app to access/edit data held in an sqlite file  
generated by another coredata app. I need to be able to access the  
data in ways not possible in the original app (not created by me)


Following some advice from this list, I have imported the datamodel  
into my app, which seems fine. I need to import data into this, and  
I've modified the sample application in Aaron Hillegass book to pull  
data from my website like the amazone example.


So far It's pulling the xml from my site, and displaying it in the  
tablevew, however I now need to loop over each row in the table, and  
create a new instance of an entity defined in the datamodel.


Can anyone point me in the right direction? I don't know how to  
reference the class in the datamodel as my class can't see it?


Many Thanks

Amy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: creating new instance of coredata entity

2008-09-11 Thread Amy Heavey
I need to add data from the website to the sqlite file created/used  
by the cocoa application.


I can pull the data in XML out of the website, and display it in a  
tableview (Aaron Hillegass sample code), but now I need to add that  
data to my app (stored in an sqlite file)


each row of the tableview contains all of the data needed, eg I have  
customers first name, last name, email address, and in the datamodel  
there is a Customer Entity (class CustomerEntity) with a firstName  
and lastName attributes, and an emailaddresses relationship.


I don't know how to loop over the tableviewdata creating new  
instances of the entity?


Many Thanks

Amy Heavey



On 11 Sep 2008, at 18:05, Jamie Hardt wrote:

How does the sqlite file relate to pulling XML from your website?   
I do not follow you there.


On Sep 11, 2008, at 1:44 AM, Amy Heavey wrote:


Hi,

Sorry for the newbie question,

I'm trying to write an app to access/edit data held in an sqlite  
file generated by another coredata app. I need to be able to  
access the data in ways not possible in the original app (not  
created by me)


Following some advice from this list, I have imported the  
datamodel into my app, which seems fine. I need to import data  
into this, and I've modified the sample application in Aaron  
Hillegass book to pull data from my website like the amazone example.


So far It's pulling the xml from my site, and displaying it in the  
tablevew, however I now need to loop over each row in the table,  
and create a new instance of an entity defined in the datamodel.


Can anyone point me in the right direction? I don't know how to  
reference the class in the datamodel as my class can't see it?


Many Thanks

Amy




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: creating new instance of coredata entity

2008-09-11 Thread Amy Heavey

Thanks,

I have got access to the datamodel, I've imported it into my xcode  
project, it's how to actually create and write the entity that i'm  
stuck on, all the examples i've found seem to use bindings and add  
buttons,


Many Thanks

Amy Heavey



On 11 Sep 2008, at 18:39, Jamie Hardt wrote:

Ah I see.  XML on web - your program - sqlite store that someone  
else's program reads/writes.


Looping over the data in the table should just be a matter of going  
through all of the items in the table's bound NSArrayController:


//code
NSArray *objectsToLoopThru =  
[myArrayControllerWithRecordsFromTheWeb arrangedObjects];


foreach (id oneObject in objectsToLoopThru) {
  //create entity
  // write entity
}

//endcode

Writing to someone elses data format is a bit trickier, since as  
you say, you don't have access to his data model.  One alternative  
is to use the low-level SQLite API to manual insert rows into his  
database, but a better one might be to read out a format that can  
be cut/pasted or imported into the third-party's application.  Does  
the other guy's app have an import function? Since it seems to be  
handling people, does it allow contacts to be imported from the  
Addressbook or vcards, in which case you could just write out the  
scraped rows to the ABAddressBook and use it as a channel.


Just a thought, take or leave.  If I were in your situation I would  
consider writing to the third party's document as a *last option*,  
since there's so many more opportunities for it to break in the  
future.


On Sep 11, 2008, at 10:22 AM, Amy Heavey wrote:

I need to add data from the website to the sqlite file created/ 
used by the cocoa application.


I can pull the data in XML out of the website, and display it in a  
tableview (Aaron Hillegass sample code), but now I need to add  
that data to my app (stored in an sqlite file)


each row of the tableview contains all of the data needed, eg I  
have customers first name, last name, email address, and in the  
datamodel there is a Customer Entity (class CustomerEntity) with a  
firstName and lastName attributes, and an emailaddresses  
relationship.


I don't know how to loop over the tableviewdata creating new  
instances of the entity?


Many Thanks

Amy Heavey




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: creating new instance of coredata entity

2008-09-11 Thread Amy Heavey

Also,

I don't have an array controller bound to the table view, the  
tableviews datasource outlet is set to the instance of my class that  
pulls the xml and processes it,


Many Thanks

Amy Heavey


On 11 Sep 2008, at 18:39, Jamie Hardt wrote:

Ah I see.  XML on web - your program - sqlite store that someone  
else's program reads/writes.


Looping over the data in the table should just be a matter of going  
through all of the items in the table's bound NSArrayController:


//code
NSArray *objectsToLoopThru =  
[myArrayControllerWithRecordsFromTheWeb arrangedObjects];


foreach (id oneObject in objectsToLoopThru) {
  //create entity
  // write entity
}

//endcode

Writing to someone elses data format is a bit trickier, since as  
you say, you don't have access to his data model.  One alternative  
is to use the low-level SQLite API to manual insert rows into his  
database, but a better one might be to read out a format that can  
be cut/pasted or imported into the third-party's application.  Does  
the other guy's app have an import function? Since it seems to be  
handling people, does it allow contacts to be imported from the  
Addressbook or vcards, in which case you could just write out the  
scraped rows to the ABAddressBook and use it as a channel.


Just a thought, take or leave.  If I were in your situation I would  
consider writing to the third party's document as a *last option*,  
since there's so many more opportunities for it to break in the  
future.


On Sep 11, 2008, at 10:22 AM, Amy Heavey wrote:

I need to add data from the website to the sqlite file created/ 
used by the cocoa application.


I can pull the data in XML out of the website, and display it in a  
tableview (Aaron Hillegass sample code), but now I need to add  
that data to my app (stored in an sqlite file)


each row of the tableview contains all of the data needed, eg I  
have customers first name, last name, email address, and in the  
datamodel there is a Customer Entity (class CustomerEntity) with a  
firstName and lastName attributes, and an emailaddresses  
relationship.


I don't know how to loop over the tableviewdata creating new  
instances of the entity?


Many Thanks

Amy Heavey




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: creating new instance of coredata entity

2008-09-11 Thread Amy Heavey

Quite possibly - off to have  go,

Thank you,

Many Thanks

Amy Heavey



On 11 Sep 2008, at 19:09, Jamie Hardt wrote:


Oh...  Is this what you mean?

NSArray *objectsToLoopThru =  
[myArrayControllerWithRecordsFromTheWeb arrangedObjects];


foreach (id oneObjectInTable in objectsToLoopThru) {
NSManagedObject *newObjectToStore = [NSEntityDescription
insertNewObjectForEntityForName:@CustomerEntity
inManagedObjectContext:myMOC];
[newObj setValue:[oneObjectInTable  
valueForKey:@firstName] forKey:@firstName];
	[newObj setValue:[oneObjectInTable valueForKey:@lastName]  
forKey:@lastName];

// etc...

}


On Sep 11, 2008, at 10:58 AM, Amy Heavey wrote:


Thanks,

I have got access to the datamodel, I've imported it into my xcode  
project, it's how to actually create and write the entity that i'm  
stuck on, all the examples i've found seem to use bindings and add  
buttons,


Many Thanks

Amy Heavey





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CoreData, SQLite and GUID

2008-08-28 Thread Amy Heavey
My biggest problem is I don't have access to the source code for the  
application that creates and uses the sqlite database.


I think I'll have to look at creating my own application,

Ideally, I need a solution that enables me to share data between  
machines (so I was thinking of a server/client type solution) but it  
also needs to run when not connected to the internet/server.


I'm a bit stuck at the moment on how to store the data for two  
situations,


Thanks,

Many Thanks

Amy Heavey


On Aug 27, 2008, at 6:30 PM, mmalc crawford wrote:



On Aug 27, 2008, at 9:33 AM, Michael Ash wrote:

On Wed, Aug 27, 2008 at 5:30 AM, Amy Heavey  
[EMAIL PROTECTED] wrote:

I use an application that I believe is written using CoreData. It is
currently quite tedious to enter data into this application, and  
the data I
need entering is already in a mysql database anyway. I'd like to  
be able to
insert this data directly into the SQLite database the  
application uses.


Nothing prevents you from programmatically manipulating your CoreData
store. CoreData is not a GUI-only technology. Get your data into some
format that your CoreData app can read, and write some code to blast
it into your store. This is much more foolproof, and probably easier,
than trying to manipulate the SQLite database directly.

To take that a step further, in principle there shouldn't be any  
need to create an intermediate format -- you should be able to  
write a utility (with or without a GUI) that reads the data from  
the MySQL database using its native library and create and store  
managed objects directly.  See http://developer.apple.com/ 
documentation/Cocoa/Conceptual/CoreData/Articles/cdImporting.html  
for hints as to how to do this efficiently.


mmalc

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/amy% 
40willowtreecrafts.co.uk


This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CoreData, SQLite and GUID

2008-08-28 Thread Amy Heavey

Do you know where this is? I can't see it in my dev folder (10.4)

Many Thanks

Amy Heavey



On Aug 28, 2008, at 6:20 PM, Aaron Burghardt wrote:

There is a good Core Data command-line utility tutorial in the  
default developer documentation that shows the details of manually  
setting up the Core Data stack.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]