UITableViewCell Red Button tap crashes app

2010-07-30 Thread Symadept
Hi,

I have a table with one section of style UITableViewCellEditingStyleDelete.
Once I click on the - button, it changes to vertical and my app crashes.
Here is the stack trace

#0  0x32043cd0 in GSEventGetType ()
#1  0x30b7109c in
-[UITableViewCellDeleteConfirmationControl(UITableViewCellDeleteConfirmationControlStatic)
_interceptEvent:] ()
#2  0x309a41bc in -[UIView(Geometry) hitTest:withEvent:] ()

#20 0x3050e47e in __NSFireTimer ()
#21 0x30254a0e in CFRunLoopRunSpecific ()
#22 0x3025416a in CFRunLoopRunInMode ()
#23 0x320452a4 in GSEventRunModal ()
#24 0x308f037c in -[UIApplication _run] ()
#25 0x308eea94 in UIApplicationMain ()
#26 0x23c0 in main (argc=1, argv=0x255c) at
/Users//dev/mpsrepos/finance/Trunk_Latest/trunk/main.m:17

Any idea regarding this.

Regards
Mustafa
___

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


Possible to hide the Drag & Drop cursor?

2010-07-30 Thread Eric Wing
I am working on a drag & drop feature where my application is the drag
destination. I want to be able to receive various types of images via
file handle, URL, data, etc.

My custom view knows how to properly display and position the images
for my specific app, better than the built-in default Mac behavior.
Because of this, I would like to suppress the default drag-and-drop
cursor image because it is a little confusing to see both
representations at the same time.

Is this possible to do?
(I saw an old post from a couple of years ago in the archives that
asked the same question but never got a response.)

Thanks,
Eric
___

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


Question about a custom UITableView (possibly)

2010-07-30 Thread Eric E. Dolecki
I've been asked about making a certain kind of control and I'm wondering
what the best approach might be.

The gist of the idea... something that looks like a UITableView, but when
you select an item (that has more information behind it), it would select
the row and animate expand the list item (height) to show a UIScrollView of
buttons that can slide left/right. Once one of those is selected, a
UITableView of items would be placed into that row related to the button
selected. One could click the row header at any time to collapse the entire
row of contents.

Should this all be made extending a UIScrollView to begin with, and then
place the necessary stuff into? Can a UITableView even approach handling the
kind of interactions I've been asked about?

Eric
___

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


[ANN] JSONKit - Yet another JSON library

2010-07-30 Thread John Engelhart
Announcing JSONKit - http://github.com/johnezang/JSONKit  A BSD Licensed
JSON serializer / deserializer.

Yes, yet another JSON library for Cocoa / Objective-C.  Why another JSON
library?  Well, if you assume that all the JSON libraries offer similar
functionality, that leaves one major metric that you can improve on: Speed.
 And that's the metric JSONKit is aimed at.  As an example, using the Sam
Soffes JSON benchmarks (
http://samsoff.es/posts/updated-iphone-json-benchmarks ,
http://github.com/samsoffes/json-benchmarks), I get the following results
when running on the iPhone simulator:

[Session started at 2010-07-30 08:57:06 -0400.]

*2010-07-30 08:57:08.431 JSONBenchmarks[754:207] Starting benchmarks with
100 iterations for each library*

*2010-07-30 08:57:09.257 JSONBenchmarks[754:207] TouchJSON average read
time  : 0.003940*

*2010-07-30 08:57:10.344 JSONBenchmarks[754:207] TouchJSON average write
time : 0.009265*

*2010-07-30 08:57:10.967 JSONBenchmarks[754:207] JSON Framework average read
time : 0.002701*

*2010-07-30 08:57:11.182 JSONBenchmarks[754:207] JSON Framework average
write time: 0.002077*

*2010-07-30 08:57:11.709 JSONBenchmarks[754:207] YAJL average read time
  : 0.001834*

*2010-07-30 08:57:11.997 JSONBenchmarks[754:207] YAJL average write time
  : 0.002652*

*2010-07-30 08:57:12.508 JSONBenchmarks[754:207] Apple JSON average read
time : 0.001746*

*2010-07-30 08:57:12.713 JSONBenchmarks[754:207] Apple JSON average write
time: 0.001975*

*2010-07-30 08:57:13.109 JSONBenchmarks[754:207] JSONKitaverage read
time : 0.000591*

*2010-07-30 08:57:13.157 JSONBenchmarks[754:207] JSONKitaverage write
time: 0.000460*

*2010-07-30 08:57:13.157 JSONBenchmarks[754:207] Done. Quitting...*

*
*
JSONKit manages to turn in some pretty impressive times relative to the
other solutions.  Benchmarks should always be taken with a grain of salt,
but I'm fairly confident that JSONKit will beat the current crop of
Objective-C JSON solutions out there.  If you're going to do some
benchmarking of your own, I'd recommend using "-O3 -DNS_BLOCK_ASSERTIONS"
for maximum performance.

One of the ways that JSONKit manages to improve "read" (i.e., deserialize
UTF8 JSON text in to Objective-C objects) times is by keeping a small cache
of recent object conversions.  This is particularly effective for JSON key /
value dictionaries where the keys tend to repeat.  Another advantage of
using a cache is that it reduces the amount of memory required for the final
Objective-C representation of the serialized JSON because an object is
instantiated only once and reused again and again.

Now, despite the obvious improvements in speed, there are some drawbacks:

- JSONKit is new.  Brand new.  Days old as of this writing.  This means
there's almost certainly bugs.  While I've done my best at ad-hoc testing,
I've yet to crank out a comprehensive unit test harness for it.

- There's no documentation, so you're pretty much on your own.  While I'm
capable of writing high quality documentation (see RegexKitLite, for
example), writing high quality documentation takes a long time to write,
usually 2-4 times longer than writing the code itself.

- The API is pretty basic.  Actually, this is a bit of an understatement.
 This reflects the current state of development which is focused more on the
internals than making use of its functionality.  :)  Feedback in this are is
appreciated.

- The guts are crufty C.  Very crufty C.  This reflects the primary
objective: speed.  The idea is to provide a quality, very fast primitive
that can be used from the comfort of Objective-C.  All the gory details are
hidden away.  Normally I wouldn't recommend this kind of optimization to
anyone, but there are exceptions to every rule.  I think there is a large
enough need for a JSON primitive that the extra effort is worth it in this
case.

- No support for garbage collection, and I doubt there ever will be.

Whether or not JSONKit continues on depends on the level of interest from
the community.  Even if JSONKit "dies", it raises the bar in terms of
performance.  A little competition can go a long way and hopefully this will
encourage the other JSON solutions out there to meet or beat the performance
of JSONKit.  To that end, I openly encourage the authors of other JSON
solutions to study JSONKit and borrow anything from JSONKit that can improve
their solution.
___

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: Cocoa-dev Digest, Vol 7, Issue 777

2010-07-30 Thread Keary Suska
On Jul 29, 2010, at 5:59 PM, Martin Stanley wrote:

>> Even if you could capture a proposed deletion before save, which AFAIK you 
>> can't, you will still have an undo mess. IMHO you best bet is to capture the 
>> situation at the point of editing the predicate, substituting the deleted 
>> item with a placeholder like "".
> I agree, trying to capture the deletion would be an unholy mess. 
> 
> But perhaps I haven't explained the problem clearly enough. The problem 
> arises not when the predicate is being edited, but when entity referenced in 
> the predicate is deleted. I need to find a way to notice this and then to 
> take corrective action. 
> 
> Also, it would be nice to let the user know that the deletion of this entity 
> will invalidate a SmartGroup. Once the model is changed appropriately I can 
> perform this check in response to the user request to delete the entity.

I was assuming that your language use was loose, but do you *really* mean 
deleting an entity, or simply deleting a managed object of that entity type? 
The former would be a horribly bad idea in most cases.

Assuming that you don't mean the above, I still don't think you are 
articulating the problem correctly. Deleting isn't the problem--Core data does 
that just fine. It seems that it is some *consequence* of the deletion that is 
the problem. What is that precisely? That a "smart group" will be invalid? 
Unless you present it otherwise to the user, it is just a predicate, and it is 
just as valid if it doesn't match anything.

But then if the problem is that you don't want this condition to occur without 
user consent--which may be a friendly feature--as long as project objects can't 
be deleted by core data internal processes (such as the result of a delete 
rule), you have complete control over the deletion, so you can check it then, 
before it even occurs.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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


IKImageView choppy?

2010-07-30 Thread Brian Postow
I have an IKImageView, and I'm putting CGImages (That I make out of NSImages) 
onto it. However, a normal 200DPI 8.5/11 page takes like 3 seconds to come up, 
appearing in rectangles about 2inches (screen) on a side at a time. This is 
really annoying. Is there a way around this?

Alternatively, is there a way to double buffer the view? To have 2 IKImageViews 
and draw into one, and then display it?


Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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


Can't get image from cacheDisplayInRect:toBitmapImageRep

2010-07-30 Thread Jørgen Tjernø
Hi,

I'm trying to capture a part of my view for use in NSView's dragImage,
but cacheDisplayInRect:toBitmapImageRep: seems to capture a blank
image. My custom NSView doesn't draw opaquely, but the region I'm
trying to capture is drawn on - my view draws a checkerboard with
except for "spacing" between each cell which is left transparent. My
NSView is contained in a stock NSBox which is contained in a stock
NSWindow.

If I load an NSImage from a file and replace "image" in the drawImage
call with this, then it shows up fine, and while the docs for
cacheDisplayInRect says that it'll produce a 100% alpha image if the
requested rect is somewhere nothing is drawn, I'm requesting an area
within the bounds of the NSView (as the log output below shows).

This is what shows up in Console.app:
self frame, bounds: {{18, 14}, {508, 508}}, {{0, 0}, {508, 508}}
tileRect: {{306, 204}, {32, 32}}

NSBitmapImageRep: NSBitmapImageRep 0x100171e00 Size={32, 32}
ColorSpace=Color LCD colorspace BPS=8 BPP=32 Pixels=32x32 Alpha=YES
Planar=NO Format=0 CurrentBacking=
NSImage: "
)>

And here is the code I use to produce the above input / attempt to
capture the display:
NSLog(@"self frame, bounds: %@, %@", NSStringFromRect([self
frame]), NSStringFromRect([self bounds]));
NSLog(@"tileRect: %@", NSStringFromRect(tileRect));
NSBitmapImageRep *imageRep = [self
bitmapImageRepForCachingDisplayInRect:tileRect];
[self cacheDisplayInRect:tileRect toBitmapImageRep:imageRep];

NSImage *image = [[[NSImage alloc] initWithSize:tileRect.size] autorelease];
[image addRepresentation:imageRep];
NSLog(@"NSBitmapImageRep: %@", imageRep);
NSLog(@"NSImage: %@", image);

NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType]
owner:self];
[pboard setString:@"Foo" forType:NSStringPboardType];

[self dragImage:image
 at:tileRect.origin
 offset:NSZeroSize
  event:theEvent
 pasteboard:pboard
 source:self
  slideBack:YES];

Any help or advice would be greatly appreciated!

Kind regards,
 Jørgen.
___

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


NSButtonCell AttributedTitle and Word Wrap

2010-07-30 Thread Fluffy D. Bunny
Hello All,

I am having an issue that is perplexing me. I have a NSMatrix using
NSButtonCells to display a series of checkboxes. Because the Text is RTF I
have to set AttributedTitle instead of Title. But even with wordwrap set to
true it will only wrap Title and never does it to AttribtuedTitle.

Has anyone out there ever dealt with this?

Thanks

FdB
___

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


Calling Matlab from Cocoa

2010-07-30 Thread Chris Goedde
Hi all,

Anyone here have any experience calling Matlab from a Cocoa program?

I have a rather complex calculation that I've implemented in Matlab that I 
would like to call from a Cocoa program. (I could re-implement it in Objective 
C if absolutely necessary, but I would prefer not to; it would probably take me 
several weeks to get right.) Matlab comes with the glue to integrate with C/C++ 
(see 
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f38569.html),
 so I think what I want to do should be possible. But, I'm trying to piece 
together several parts from different environments, and I could really benefit 
from a brief high-level road map.

So, if anyone has done something like this, I'd really appreciate a couple of 
pointers to set me off in the right direction. Thanks.

Chris Goedde



___

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


does anyone use IKImageView?

2010-07-30 Thread Brian Postow
I've been following this list for a while, and have seen very few questions 
about the IK family, even though I've had a series of problems with it. Is it 
known that it is a lousy way to do things? or am I the only one who has these 
problems?


Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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: Calling Matlab from Cocoa

2010-07-30 Thread Sherm Pendley
On Fri, Jul 30, 2010 at 1:00 PM, Chris Goedde  wrote:
>
> Anyone here have any experience calling Matlab from a Cocoa program?
>
> I have a rather complex calculation that I've implemented in Matlab that I 
> would like to call from a Cocoa program. (I could re-implement it in 
> Objective C if absolutely necessary, but I would prefer not to; it would 
> probably take me several weeks to get right.) Matlab comes with the glue to 
> integrate with C/C++ (see 
> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f38569.html),
>  so I think what I want to do should be possible.

Remember, Objective-C *is* C. The easiest thing to do IMHO would be to
simply call the C functions.

sherm--

-- 
Cocoa programming in Perl:
http://www.camelbones.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/archive%40mail-archive.com

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


Re: does anyone use IKImageView?

2010-07-30 Thread douglas welton
Hi Brian,

I'm pretty sure that the volume of questions on a mailing list is not a direct 
indicator of software quality, but we'll leave that discussion for another 
time. ;^}

Do you have a specific question regarding IKImageView that you would like to 
post?  Have you checked out the Quartz mailing list? People sometimes ask 
questions there as well.  And as always, the list archives are your friend...

regards,

douglas

On Jul 30, 2010, at 1:18 PM, Brian Postow wrote:

> I've been following this list for a while, and have seen very few questions 
> about the IK family, even though I've had a series of problems with it. Is it 
> known that it is a lousy way to do things? or am I the only one who has these 
> problems?
> 
> 
> Brian Postow
> Senior Software Engineer
> Acordex Imaging Systems

___

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: does anyone use IKImageView?

2010-07-30 Thread Brian Postow

On Jul 30, 2010, at 1:32 PM, douglas welton wrote:

> Hi Brian,
> 
> I'm pretty sure that the volume of questions on a mailing list is not a 
> direct indicator of software quality, but we'll leave that discussion for 
> another time. ;^}
> 
> Do you have a specific question regarding IKImageView that you would like to 
> post?  Have you checked out the Quartz mailing list? People sometimes ask 
> questions there as well.  And as always, the list archives are your friend...


Well, part of the reason for my question is that I asked two questions about 
IKImageView in the past few days and gotten no responses... It was as if no one 
here knows anything about the ImageKit. is it more properly part of Quartz? 
I'll ask there as well.

thanks.


Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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: does anyone use IKImageView?

2010-07-30 Thread Quincey Morris
On Jul 30, 2010, at 10:18, Brian Postow wrote:

> I've been following this list for a while, and have seen very few questions 
> about the IK family, even though I've had a series of problems with it. Is it 
> known that it is a lousy way to do things? or am I the only one who has these 
> problems?

I don't think you're the only one who's had problems, but I think you may have 
persisted longer in the face of problems than anyone else. (I only lasted a day 
and a half with it, before I took my code, burned it, and buried it with plenty 
of garlic at a nearby crossroads.)

From my limited experience with IK, I'd say its main problem is its 
inscrutability. It general purpose is clear, but there isn't much information 
about what it's supposed to do in any given situation, whether it has any given 
behavior, and how to get the behaviors it has to operate. Possibly it's 
extremely buggy, but it's too inscrutable to determine whether specific cases 
are (a) bugs, (b) you're Doing It Wrong™, or (c) it Doesn't Do That™.

It seems to me IK is one of a handful of frameworks that suffers from gross 
design-by-implementation. That is, what it's supposed to do is defined by what 
it actually does, which is not much help to the developer. Unlike with most 
frameworks, the API isn't really a contract with the developer, but more a 
series of "Push Here For A Chance To Win" buttons.

FWIW.


___

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


Accessing items in a UIScrollView?

2010-07-30 Thread Eric E. Dolecki
I am trying to quickly prototype something - I am stuffing a bunch of
subclassed UIButton controls into a UIScrollView. I would like to access
those items later from another method, but I don't know how to properly
access them without resorting to an NSArray approach.

I have this (setState is a method in the BasicListItem subclassed UIButton
class):

int yPos = 0;

for(int i = 0; i<20; i++ ){

BasicListItem *listItem = [[BasicListItem alloc]

   initWithFrame:CGRectMake(9,yPos,302,26)];

listItem.tag = i;

[listItem setTitleColor:[UIColor blackColor]
forState:UIControlStateNormal];

[listItem setTitle:@" Music" forState:UIControlStateNormal];

[listItem addTarget:self action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];

yPos += 44;

[scrollView addSubview:listItem];

//[itemView addSubview:listItem];

}



scrollView.contentSize = CGSizeMake(itemView.frame.size.width, yPos);

}


In another method I try to access all of those elements in the scrollview...
(which barfs)


 -(void) buttonClicked:(id)sender

{

int tag = [sender tag];

for(int i=0;i<20;i++){

BasicListItem *tmp = (BasicListItem*)[scrollView viewWithTag:i];

if( tag != i ){

[tmp setState:NO]; //Barf here

}

}

NSLog(@"%d",tag);

}


*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UIScrollView setState:]: unrecognized selector sent to instance
0x593e820'


How can I dig into the scrollview and access those BasicListItem objects?
___

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: Accessing items in a UIScrollView?

2010-07-30 Thread Fritz Anderson
On 30 Jul 2010, at 2:14 PM, Eric E. Dolecki wrote:

> -(void) buttonClicked:(id)sender
> {
>int tag = [sender tag];
> 
>for(int i=0;i<20;i++){
>BasicListItem *tmp = (BasicListItem*)[scrollView viewWithTag:i];
> 
>if( tag != i ){
>[tmp setState:NO]; //Barf here
>}
>}
>NSLog(@"%d",tag);
> }
> 
> 
> *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
> reason: '-[UIScrollView setState:]: unrecognized selector sent to instance
> 0x593e820'
> 
> 
> How can I dig into the scrollview and access those BasicListItem objects?

1. Use the blasted NSArray. It's a data structure that accesses a group of 
objects in order, by a numeric index, and can be efficiently iterated. That's 
what you want.

-(void) buttonClicked: (id) sender
{
for (BasicListItem * item in self.listItemArray)
item.state = (item == sender);
}

2. This is what the documentation says -[UIView viewWithTag:] returns:

> The view in the receiver’s hierarchy that matches tag. The receiver is 
> included in the search.

I assume you left the scroll view's tag at zero? The exception label is the 
clue: It says you sent setState: to the scroll view.

— F

___

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: Accessing items in a UIScrollView?

2010-07-30 Thread Eric E. Dolecki
Thanks - I'm just using a NSMutable array now and doing it that way which
works great.

On Fri, Jul 30, 2010 at 3:30 PM, Fritz Anderson wrote:

> On 30 Jul 2010, at 2:14 PM, Eric E. Dolecki wrote:
>
> > -(void) buttonClicked:(id)sender
> > {
> >int tag = [sender tag];
> >
> >for(int i=0;i<20;i++){
> >BasicListItem *tmp = (BasicListItem*)[scrollView viewWithTag:i];
> >
> >if( tag != i ){
> >[tmp setState:NO]; //Barf here
> >}
> >}
> >NSLog(@"%d",tag);
> > }
> >
> >
> > *** Terminating app due to uncaught exception
> 'NSInvalidArgumentException',
> > reason: '-[UIScrollView setState:]: unrecognized selector sent to
> instance
> > 0x593e820'
> >
> >
> > How can I dig into the scrollview and access those BasicListItem objects?
>
> 1. Use the blasted NSArray. It's a data structure that accesses a group of
> objects in order, by a numeric index, and can be efficiently iterated.
> That's what you want.
>
> -(void) buttonClicked: (id) sender
> {
>for (BasicListItem * item in self.listItemArray)
>item.state = (item == sender);
> }
>
> 2. This is what the documentation says -[UIView viewWithTag:] returns:
>
> > The view in the receiver’s hierarchy that matches tag. The receiver is
> included in the search.
>
> I assume you left the scroll view's tag at zero? The exception label is the
> clue: It says you sent setState: to the scroll view.
>
>— F
>
>


-- 
http://ericd.net
Interactive design and development
___

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


[iPhone] Nib Loading Question

2010-07-30 Thread Development
I have a nib with two views in it. however the only view that loads is the one 
connected to the view outlet in the view controller. How can I get the second 
view to load?___

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: Intercepting deletion of NSManagedObjects or how to handle deletion in non-explicit relationships?

2010-07-30 Thread Martin Stanley
Thanks for helping me analyze the situation more carefully.

Yes, I do mean deleting "a managed object of that entity type". (I come from a 
modelling background where we commonly used the word "entity" to mean an object 
of a particular type/class.)

And yes, deletes are not the problem. You are correct that it is the 
consequence of the delete that is the problem. 

What happens is two-fold:
1- the predicate is "invalid". It references (as an NSString) an non-existent 
project, for example. This in and of itself is not the major problem as you 
point out.
2- the invalid predicate breaks the NSPredicateEditor. My 
NSPredicateEditorRowTemplate subclass populates its popup button dynamically 
based on the current contents of an NSArrayController bound to the entity in 
question (e.g., Project). When it tries to match the popup to this predicate it 
complains because there is no longer an entry matching the deleted object's 
name.

However, following your last suggestion, I think the following should work:
- when a SmartGroup is created, register an observer on its predicate attribute.
- then whenever the predicate is changed:
- parse the predicate to find all of the objects mentioned (by name), 
and 
- create a bi-directional reference between each object and this 
SmartGroup object
- then when attempting to delete the object (e.g. a Project) inform the user 
and, if given the go-ahead, clean up all predicates which reference the object 
before asking Core Data to delete the object.


Martin Stanley
Thinking Ventures
m...@thinkingventures.com



On 2010-07-30, at 10:13 AM, Keary Suska wrote:

> On Jul 29, 2010, at 5:59 PM, Martin Stanley wrote:
> 
>>> Even if you could capture a proposed deletion before save, which AFAIK you 
>>> can't, you will still have an undo mess. IMHO you best bet is to capture 
>>> the situation at the point of editing the predicate, substituting the 
>>> deleted item with a placeholder like "".
>> I agree, trying to capture the deletion would be an unholy mess. 
>> 
>> But perhaps I haven't explained the problem clearly enough. The problem 
>> arises not when the predicate is being edited, but when entity referenced in 
>> the predicate is deleted. I need to find a way to notice this and then to 
>> take corrective action. 
>> 
>> Also, it would be nice to let the user know that the deletion of this entity 
>> will invalidate a SmartGroup. Once the model is changed appropriately I can 
>> perform this check in response to the user request to delete the entity.
> 
> I was assuming that your language use was loose, but do you *really* mean 
> deleting an entity, or simply deleting a managed object of that entity type? 
> The former would be a horribly bad idea in most cases.
> 
> Assuming that you don't mean the above, I still don't think you are 
> articulating the problem correctly. Deleting isn't the problem--Core data 
> does that just fine. It seems that it is some *consequence* of the deletion 
> that is the problem. What is that precisely? That a "smart group" will be 
> invalid? Unless you present it otherwise to the user, it is just a predicate, 
> and it is just as valid if it doesn't match anything.
> 
> But then if the problem is that you don't want this condition to occur 
> without user consent--which may be a friendly feature--as long as project 
> objects can't be deleted by core data internal processes (such as the result 
> of a delete rule), you have complete control over the deletion, so you can 
> check it then, before it even occurs.
> 
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
> 

___

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: Calling Matlab from Cocoa

2010-07-30 Thread Chris Goedde
On Jul 30, 2010, at 12:27 PM, Sherm Pendley wrote:

> On Fri, Jul 30, 2010 at 1:00 PM, Chris Goedde  wrote:
>> 
>> Anyone here have any experience calling Matlab from a Cocoa program?
>> 
>> I have a rather complex calculation that I've implemented in Matlab that I 
>> would like to call from a Cocoa program. (I could re-implement it in 
>> Objective C if absolutely necessary, but I would prefer not to; it would 
>> probably take me several weeks to get right.) Matlab comes with the glue to 
>> integrate with C/C++ (see 
>> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f38569.html),
>>  so I think what I want to do should be possible.
> 
> Remember, Objective-C *is* C. The easiest thing to do IMHO would be to
> simply call the C functions.

That's what I was originally hoping to do, but I don't think it's that simple. 
As far as I can tell, it's not just a matter of including the right headers and 
linking to the right libraries. But maybe I'm not understanding the 
documentation correctly; that's why I was hoping to hear from someone who had 
actually done this with Cocoa.

Chris

___

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: Intercepting deletion of NSManagedObjects or how to handle deletion in non-explicit relationships?

2010-07-30 Thread Kyle Sluder
On Fri, Jul 30, 2010 at 2:11 PM, Martin Stanley
 wrote:
> 2- the invalid predicate breaks the NSPredicateEditor. My 
> NSPredicateEditorRowTemplate subclass populates its popup button dynamically 
> based on the current contents of an NSArrayController bound to the entity in 
> question (e.g., Project). When it tries to match the popup to this predicate 
> it complains because there is no longer an entry matching the deleted 
> object's name.
>
> However, following your last suggestion, I think the following should work:
> - when a SmartGroup is created, register an observer on its predicate 
> attribute.
> - then whenever the predicate is changed:
>        - parse the predicate to find all of the objects mentioned (by name), 
> and
>        - create a bi-directional reference between each object and this 
> SmartGroup object
> - then when attempting to delete the object (e.g. a Project) inform the user 
> and, if given the go-ahead, clean up all predicates which reference the 
> object before asking Core Data to delete the object.

I think you're going about this backwards. Your predicate should
already be modeled in the document (by a SmartGroup entity or a
collection of related entities) and the predicate editor's delegate
should be the controller responsible for converting between the
predicate editor's representation and your model representation. This
would be evidence of a good MVC design.

--Kyle Sluder
___

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


Determine encoding of file

2010-07-30 Thread Dave DeLong
Hi everyone,

I have a seemingly simple question, but I haven't been able to figure it out.

Given a file, how can I determine the NSStringEncoding of the file, without 
reading the entire file into memory?  (If the file isn't a text file, then 
defaulting to NSUTF8StringEncoding is just fine, since my code will only work 
properly if I'm working with text files anyway)

I've found this: http://www.macosxguru.net/article.php?story=20030808081801868 
but it seems ridiculously complex...

Thanks,

Dave

smime.p7s
Description: S/MIME cryptographic signature
___

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: Determine encoding of file

2010-07-30 Thread Nick Zitzmann

On Jul 30, 2010, at 4:09 PM, Dave DeLong wrote:

> Hi everyone,
> 
> I have a seemingly simple question, but I haven't been able to figure it out.
> 
> Given a file, how can I determine the NSStringEncoding of the file, without 
> reading the entire file into memory?  (If the file isn't a text file, then 
> defaulting to NSUTF8StringEncoding is just fine, since my code will only work 
> properly if I'm working with text files anyway)
> 
> I've found this: 
> http://www.macosxguru.net/article.php?story=20030808081801868 but it seems 
> ridiculously complex...

Check the first two bytes. If they are 0xFEFF or 0xFFFE, then it is guaranteed 
to be in Unicode (UTF-16) format. Otherwise, it can be in pretty much any 
format, since pretty much every format that is not Unicode doesn't use 
identifiers of any sort.

NSAttributedString has a heuristic importer in its AppKit category that tries 
to guess the encoding of the file, 
-initWithData:options:documentAttributes:error:, but it is not perfect (in 
particular, it tends to mistake data in UTF-8 format for something else). So if 
it's not Unicode, then you're probably better off just asking the user to tell 
the program the encoding of the file. We ended up doing this in several of our 
apps.

Nick Zitzmann


___

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: Determine encoding of file

2010-07-30 Thread Kyle Sluder
On Fri, Jul 30, 2010 at 3:09 PM, Dave DeLong  wrote:
> Hi everyone,
>
> I have a seemingly simple question, but I haven't been able to figure it out.
>
> Given a file, how can I determine the NSStringEncoding of the file, without 
> reading the entire file into memory?  (If the file isn't a text file, then 
> defaulting to NSUTF8StringEncoding is just fine, since my code will only work 
> properly if I'm working with text files anyway)

There's no standard heuristic for doing this. Windows has one built in
called MLang that IE uses, but I don't think the heuristic itself is
published. Encoding detection also happens to be the source of many
humorous "bugs" in Notepad:
http://blogs.msdn.com/b/michkap/archive/2006/06/14/631016.aspx

> I've found this: 
> http://www.macosxguru.net/article.php?story=20030808081801868 but it seems 
> ridiculously complex...

That is pretty poorly engineered code: an explosion of classes for no
good reason. If I were to write an encoding detector, it would
probably be a much simpler big if block.

--Kyle Sluder
___

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: Determine encoding of file

2010-07-30 Thread John Pannell
Hi Dave-

I have some code I've been using for a few years for this purpose... when I 
consulted Google on the source of the TECSniffer class that I have, the search 
was not revealing.  So... I've posted the class files here:

http://www.positivespinmedia.com/dev/TEC.zip

I believe it is using some carbon-y Text Encoding Converter goodness, but could 
not say for sure.  The code is called like so in my app:

TECSniffer *sniffer = [[TECSniffer alloc] initWithWebTextEncodings];
NSArray *results = [sniffer sniff:_htmldata];
while(!htmlString && i < [results count]){
htmlString = [[NSString alloc] initWithData:_htmldata 
encoding:[[results objectAtIndex:i] unsignedIntValue]];
}

I didn't write the original code, and couldn't track down the origination of 
it.  Perhaps it will help!

John

On Jul 30, 2010, at 4:09 PM, Dave DeLong wrote:
> 
> I have a seemingly simple question, but I haven't been able to figure it out.
> 
> Given a file, how can I determine the NSStringEncoding of the file, without 
> reading the entire file into memory?  (If the file isn't a text file, then 
> defaulting to NSUTF8StringEncoding is just fine, since my code will only work 
> properly if I'm working with text files anyway)
> 
> I've found this: 
> http://www.macosxguru.net/article.php?story=20030808081801868 but it seems 
> ridiculously complex...
> 

___

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


drawingRectForBounds not being called

2010-07-30 Thread Tony Romano
I have an NSTextTextField in my nib that is using a custom NSTextFieldCell (set 
in IB) class that has only one method over-riden, drawingRectForBounds.  The 
method is not being called.  This is what I have done.

1. Set  a break point to verify it is not being called.
2. Using F-Script, verified that the instance of NSTextField is using my custom 
cell.  I can invoke my method via F-Script as well.
3. Verified the correct spelling and signature of the method.

Anyone have other ideas as to what I am overlooking?

Thanks,
-Tony

___

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: drawingRectForBounds not being called

2010-07-30 Thread Kyle Sluder
On Fri, Jul 30, 2010 at 3:38 PM, Tony Romano  wrote:
> I have an NSTextTextField in my nib that is using a custom NSTextFieldCell 
> (set in IB) class that has only one method over-riden, drawingRectForBounds.  
> The method is not being called.  This is what I have done.
>
> 1. Set  a break point to verify it is not being called.
> 2. Using F-Script, verified that the instance of NSTextField is using my 
> custom cell.  I can invoke my method via F-Script as well.
> 3. Verified the correct spelling and signature of the method.

Are you certain? The method is named -drawingRectForBounds:. Since you
omitted the colon above, I am wondering if you have in fact misspelled
the method.

Please post your code.

--Kyle Sluder
___

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: drawingRectForBounds not being called

2010-07-30 Thread Tony Romano
@interface ViewStatusTextCell : NSTextFieldCell

- (NSRect)drawingRectForBounds:(NSRect)theRect;

@end

- (NSRect)drawingRectForBounds:(NSRect)theRect
{
NSRect rect = [super drawingRectForBounds:theRect];
NSSize textSize = [self cellSizeForBounds:theRect];

NSUInteger heightDelta = rect.size.height - textSize.height;
if (heightDelta > 0) {
rect.size.height -= heightDelta;
rect.origin.y += heightDelta/2;
}

return rect;
}

On Jul 30, 2010, at 4:03 PM, Kyle Sluder wrote:

> On Fri, Jul 30, 2010 at 3:38 PM, Tony Romano  wrote:
>> I have an NSTextTextField in my nib that is using a custom NSTextFieldCell 
>> (set in IB) class that has only one method over-riden, drawingRectForBounds. 
>>  The method is not being called.  This is what I have done.
>> 
>> 1. Set  a break point to verify it is not being called.
>> 2. Using F-Script, verified that the instance of NSTextField is using my 
>> custom cell.  I can invoke my method via F-Script as well.
>> 3. Verified the correct spelling and signature of the method.
> 
> Are you certain? The method is named -drawingRectForBounds:. Since you
> omitted the colon above, I am wondering if you have in fact misspelled
> the method.
> 
> Please post your code.
> 
> --Kyle Sluder
> 

-Tony

___

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: Determine encoding of file

2010-07-30 Thread Martin Wierschin
Given a file, how can I determine the NSStringEncoding of the file,  
without reading the entire file into memory?


Some files may have a text encoding attribute set, which you can read  
using getxattr and "com.apple.textEncoding". Probably you won't have  
the luxury of just using that API, but since it hadn't been mentioned  
yet I wanted to bring it up.


The most important thing is that you let your users override whatever  
heuristic you choose as a default.


~Martin

___

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: Determine encoding of file

2010-07-30 Thread Michael Watson
There's a good session from WWDC 2009, 112 - Text Processing in Cocoa, that has 
a segment about guessing encodings without having to read the entire file (in 
most cases). It's worth watching, even if it doesn't solve your problem 
directly.


--
michael

On 30 Jul, 2010, at 15:09, Dave DeLong wrote:

> Hi everyone,
> 
> I have a seemingly simple question, but I haven't been able to figure it out.
> 
> Given a file, how can I determine the NSStringEncoding of the file, without 
> reading the entire file into memory?  (If the file isn't a text file, then 
> defaulting to NSUTF8StringEncoding is just fine, since my code will only work 
> properly if I'm working with text files anyway)
> 
> I've found this: 
> http://www.macosxguru.net/article.php?story=20030808081801868 but it seems 
> ridiculously complex...
> 
> Thanks,
> 
> Dave___
> 
> 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/mikey-san%40bungie.org
> 
> This email sent to mikey-...@bungie.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/archive%40mail-archive.com

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


Re: Determine encoding of file

2010-07-30 Thread Michael Watson
And, of course, as Nick Z and that session point out, you may need to allow the 
user to choose the encoding somehow in your application, given you can't be 
100% accurate when the encoding is unknown.


--
michael

On 30 Jul, 2010, at 17:35, Michael Watson wrote:

> There's a good session from WWDC 2009, 112 - Text Processing in Cocoa, that 
> has a segment about guessing encodings without having to read the entire file 
> (in most cases). It's worth watching, even if it doesn't solve your problem 
> directly.
> 
> 
> --
> michael
> 
> On 30 Jul, 2010, at 15:09, Dave DeLong wrote:
> 
>> Hi everyone,
>> 
>> I have a seemingly simple question, but I haven't been able to figure it out.
>> 
>> Given a file, how can I determine the NSStringEncoding of the file, without 
>> reading the entire file into memory?  (If the file isn't a text file, then 
>> defaulting to NSUTF8StringEncoding is just fine, since my code will only 
>> work properly if I'm working with text files anyway)
>> 
>> I've found this: 
>> http://www.macosxguru.net/article.php?story=20030808081801868 but it seems 
>> ridiculously complex...
>> 
>> Thanks,
>> 
>> Dave___
>> 
>> 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/mikey-san%40bungie.org
>> 
>> This email sent to mikey-...@bungie.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/archive%40mail-archive.com

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


Re: Determine encoding of file

2010-07-30 Thread Rainer Brockerhoff
At 16:06 -0700 30/07/10, cocoa-dev-requ...@lists.apple.com wrote:
>From: Dave DeLong 
>Date: Fri, 30 Jul 2010 16:09:22 -0600
>Message-ID: 
>...
>Given a file, how can I determine the NSStringEncoding of the file, without 
>reading the entire file into memory?  (If the file isn't a text file, then 
>defaulting to NSUTF8StringEncoding is just fine, since my code will only work 
>properly if I'm working with text files anyway)

Beyond what others have already answered, one example heuristic can be found in 
this sample code:
http://brockerhoff.net/src/FolderSweep.zip
check the last method in AppController.m.

HTH,
-- 
Rainer Brockerhoff  
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
 In their own business even sages err."
Blog: http://brockerhoff.net/blog
___

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: Intercepting deletion of NSManagedObjects or how to handle deletion in non-explicit relationships?

2010-07-30 Thread Martin Stanley
Hmm. I realize that this seems unconventional; that is why I posed the question 
in the first place.

Perhaps you know something about NSPredicateEditor that I don't, but I think it 
does not use its delegate in the way you envision. To quote from the docs:
--
Unlike NSRuleEditor, NSPredicateEditor does not depend on its delegate to 
populate its rows (and does not call the populating delegate methods). Instead, 
its rows are populated from its objectValue property (an instance 
ofNSPredicate). NSPredicateEditor relies on instances 
NSPredicateEditorRowTemplate, which are responsible for mapping back and forth 
between the displayed view values and various predicates.
--

In my design, the predicate *is* modelled as an attribute of the SmartGroup 
entity/class. I have a view controller which instantiates a number of 
NSPredicateEditorRowTemplates and connects them to an instance of a subclass of 
NSPredicateEditor. It is this predicate editor which allows the user to modify 
the predicate. The view controller does not have the ability to interject 
itself into the predicate creation. This is handled completely within 
NSpredicateEditor with the help of its NSPredicateEditorRowTemplates. 

However, my subclass of NSPredicateEditor overrides the objectValue method (to 
catch errors such as the one I described earlier). It would be possible to 
parse the predicate and create back-pointers at this point. This is called 
every time the predicate is changed. Would this be a better approach?

Martin



On 2010-07-30, at 5:51 PM, Kyle Sluder wrote:

> On Fri, Jul 30, 2010 at 2:11 PM, Martin Stanley
>  wrote:
>> 2- the invalid predicate breaks the NSPredicateEditor. My 
>> NSPredicateEditorRowTemplate subclass populates its popup button dynamically 
>> based on the current contents of an NSArrayController bound to the entity in 
>> question (e.g., Project). When it tries to match the popup to this predicate 
>> it complains because there is no longer an entry matching the deleted 
>> object's name.
>> 
>> However, following your last suggestion, I think the following should work:
>> - when a SmartGroup is created, register an observer on its predicate 
>> attribute.
>> - then whenever the predicate is changed:
>>- parse the predicate to find all of the objects mentioned (by name), 
>> and
>>- create a bi-directional reference between each object and this 
>> SmartGroup object
>> - then when attempting to delete the object (e.g. a Project) inform the user 
>> and, if given the go-ahead, clean up all predicates which reference the 
>> object before asking Core Data to delete the object.
> 
> I think you're going about this backwards. Your predicate should
> already be modeled in the document (by a SmartGroup entity or a
> collection of related entities) and the predicate editor's delegate
> should be the controller responsible for converting between the
> predicate editor's representation and your model representation. This
> would be evidence of a good MVC design.
> 
> --Kyle Sluder

___

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: Determine encoding of file

2010-07-30 Thread Michael Ash
On Fri, Jul 30, 2010 at 6:24 PM, Nick Zitzmann  wrote:
>
> On Jul 30, 2010, at 4:09 PM, Dave DeLong wrote:
>
>> Hi everyone,
>>
>> I have a seemingly simple question, but I haven't been able to figure it out.
>>
>> Given a file, how can I determine the NSStringEncoding of the file, without 
>> reading the entire file into memory?  (If the file isn't a text file, then 
>> defaulting to NSUTF8StringEncoding is just fine, since my code will only 
>> work properly if I'm working with text files anyway)
>>
>> I've found this: 
>> http://www.macosxguru.net/article.php?story=20030808081801868 but it seems 
>> ridiculously complex...
>
> Check the first two bytes. If they are 0xFEFF or 0xFFFE, then it is 
> guaranteed to be in Unicode (UTF-16) format. Otherwise, it can be in pretty 
> much any format, since pretty much every format that is not Unicode doesn't 
> use identifiers of any sort.

A nitpick: starting with those two bytes is a *strong suggestion* that
it's UTF-16, but it could just be, say, a Latin-1 file that starts
with "þÿ", or a random binary file that happens to start with that
byte sequence.

One fact that's can be extremely useful for this sort of thing but
which seems to be little-known: due to the structure of UTF-8 it's
rare for a file to be valid UTF-8 by accident. Random data, or data
that isn't intended to be structured like UTF-8, is extremely unlikely
to happen to match the structure required by UTF-8 by coincidence.
Thus, if a file parses as UTF-8, you can be pretty confident that it
was supposed to be interpreted in that encoding.

The same is, alas, not true of UTF-16.

Mike
___

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: Intercepting deletion of NSManagedObjects or how to handle deletion in non-explicit relationships?

2010-07-30 Thread Kyle Sluder
On Fri, Jul 30, 2010 at 7:37 PM, Martin Stanley
 wrote:
> Perhaps you know something about NSPredicateEditor that I don't, but I think 
> it does not use its delegate in the way you envision. To quote from the docs:

You are correct. I was thinking of NSRuleEditor.

> However, my subclass of NSPredicateEditor overrides the objectValue method 
> (to catch errors such as the one I described earlier). It would be possible 
> to parse the predicate and create back-pointers at this point. This is called 
> every time the predicate is changed. Would this be a better approach?

Yes, I would expect that whatever controller is setting and retrieving
the objectValue from the predicate editor would be doing the necessary
communication with the model to keep the view and model in a
consistent state. The best thing to do might be to use this
opportunity to convert from NSPredicate instances (for the predicate
editor's objectValue) to collections of managed objects that model the
predicate. Then Core Data delete rules and validation will take care
of all the consistency, rather than forcing this logic into the
controller or view.

--Kyle Sluder
___

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