Re: Referencing NSData's length in a predicate?

2009-11-27 Thread Jerry Krinock

On 2009 Nov 27, at 22:03, Dave DeLong wrote:

> I have a Core Data object called "Item".  One of its attributes is a binary 
> attribute called "data".  I've constructed a fetch request to retrieve all 
> Items based on the length of the data (ex: "data.length <= 1024").  I *know* 
> that I have Items with data less than 1KB, yet when I execute this predicate, 
> it doesn't seem to be returning anything (nothing shows up in my NSTableView 
> of results, while the results of every other fetch request show up just fine).

Are you using the sqlite store?

Is data.length an integer attribute of your 'Item', or are you sending the 
-length message to an NSData object in the store?  In the first case, it should 
work.  In the second case, in my experience, it will not work.  See the answer 
I posted to Ron Aldrich's issue a few hours ago on this list.  Core Data 
predicates are quite limited when fetching from an sqlite store.  Just because 
you can write a predicate and Xcode compiles it doesn't mean it will work.

But then I read this:

> data.length == 414 => returns 0 of 153 items
> data.length != 414=> returns 153 of 153 items
> data.length < 415 => returns 1 item (size 251B)
> data.length <= 414 => returns 1 item (size 251B)
> data.length >= 414 => returns 151 of 153 items
> data.length > 413 => returns 151 of 153 items

I'm not sure if this result is from your array-controller filtering or from 
your Core Data fetch.  My hypothesis is that array-controller filtering will 
always work and Core Data fetch from sqlite will always return 0 results.  But 
it looks like your results are mixed, so I'm confused.

As I suggested at the beginning, if you *really* want to do this kind of fetch 
from an sqlite store, 'length' needs to be a "column in the table" (in database 
lingo).  In Core Data lingo, add an integer attribute, 'length'.  It seems 
silly at first, but it's really not that bad.  Create a custom setter for 
'data', and in this -setData:, invoke -setLength:[data length].

> I haven't found anything in the documentation that indicates that this 
> wouldn't work, so can you help me see what I'm missing?

As I told Ron, you must read between the lines.

___

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: Global Object

2009-11-27 Thread Jens Alfke

On Nov 26, 2009, at 9:18 AM, Tom Jones wrote:

> I thought I could just create a Global variable but that does not work.

Did you make it a pointer? You can't directly declare instances of any Cocoa 
classes, only pointers to them.

So
MyCocoaClass gFoo;
is a syntax error, while
MyCocoaClass *gFoo;
works.

Of course, you need some initialization code that allocates a new object and 
assigns it to foo. And you have to be sure that this code will run before 
anyone else tries to use gFoo. This can be problematic. Putting this code into 
your app delegate's awakeFromNib method is often sufficient, via something like 
this:

- (void) awakeFromNib {
gFoo = [[MyCocoaClass alloc] init];
}

Another way is to do the initialization in a class's +initialize method.

—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/archive%40mail-archive.com

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


Re: Getting the path to an application with a launchDaemon

2009-11-27 Thread Jens Alfke

On Nov 27, 2009, at 12:08 AM, Zephyroth Akash wrote:

> I'm actually creating a daemon which then runs in root context and I can't 
> get the path to an application.
> The command: [[NSWorkspace sharedWorkspace] 
> absolutePathForAppBundleIdentifier:@"com.myCompany.myApp"]; returns NULL but 
> returns the path to my application bundle correctly if used as a user.

I don't believe NSWorkspace works correctly when run as root. While root is a 
real userid at the Unix level, it's not intended that anyone ever log into the 
GUI with that userid, so a lot of the higher-level system frameworks don't 
support it.

Anyway, in keeping with the "Principle Of Least Privilege", it's best not to 
run as root if there is any way around it. There's too much danger if anything 
goes wrong, since you can delete or overwrite anything. Worse, it's all too 
easy for malware to exploit poorly-written software that runs as root, by 
tricking it into following the wrong instructions or calling the wrong helper 
tool. (Plenty of Apple's security-fix system patches have addressed issues like 
these.)

Can you write your program as a background agent that runs as the currently 
logged-in user? This is a lot easier and safer. (Frankly, I would avoid using 
Cocoa APIs for any code that runs as root.)

—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/archive%40mail-archive.com

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


Re: An Array of structs

2009-11-27 Thread Jens Alfke

On Nov 27, 2009, at 7:48 AM, Alastair Houghton wrote:

> You *can* have non-constant elements in struct initialisers in C, *but* only 
> in a context where there is code that will execute at runtime.

C++ eliminates most of these restrictions, btw. And you can make your code C++ 
simply by changing the suffix from ".m" to ".mm".

That said, I've found that putting Obj-C object pointers in C/C++ structs can 
be very painful, due to refcounting issues. It's easy to copy the structs 
around, but doing so doesn't bump the refcounts of the objects they point to, 
so you can end up with dangling pointers to dealloced objects. (There are ways 
around this but they involve building C++ smart pointer classes to manage the 
Obj-C refcounts...)

—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/archive%40mail-archive.com

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


Re: Apache Module

2009-11-27 Thread Jens Alfke

On Nov 27, 2009, at 10:34 PM, Mr. Gecko wrote:

> The reason I'm posting in this list is because I'm trying to write a module 
> in objective-c that will work with apache and this is a list on objective-c 
> and I know I wouldn't get much of a reply on the apache lists.

The issues involved in this task don't really have anything to do with 
Objective-C; they have to do with integrating with a web server.

And to the extent that you have questions about things like how to link the 
module or how to set up an Xcode project for it, those are best asked on the 
xcode mailing list.

> And I'm not writing a apache module just for a web application, I'm writing 
> it so I can get the language of Objective-C to the web easier and better.

It's not necessary to write an Apache module to do that. For example, Python 
and Ruby are both extremely popular for web development and neither of them 
uses a special Apache module. (There is an old mod_python, but no one uses it.) 
They use either SCGI or proxying. AFAIK the same is true of Java. PHP is kind 
of an oddball.

That's what I meant by the machine-shop analogy. Apache modules are hard to 
write, can break the web server if they go wrong, and are generally used for 
specific low-level purposes, mostly infrastructure.

—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/archive%40mail-archive.com

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


Re: Inconsistent results from iconForFile

2009-11-27 Thread Jens Alfke

On Nov 27, 2009, at 10:31 PM, Sandy McGuffog wrote:

> For some files, I get a thumbnail of the file, so e.g., for a JPEG, I get a 
> miniature of the actual image in the JPEG. But for other files, even in the 
> same directory, I get the file type icon, so e.g., for a JPEG, the OS X JPEG 
> icon.
> 
> All these files show the miniature of the image in Finder.


Some files have embedded previews, or are in common formats (like JPEG) that 
the system at a low level knows how to generate preview of — NSWorkspace etc. 
will give you previews of those. But not all file types are like that. If 
you're trying to get icon previews of all kinds of files, the QuickLook API is 
the best way to do 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/archive%40mail-archive.com

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


Re: Apache Module

2009-11-27 Thread Mr. Gecko
The reason I'm posting in this list is because I'm trying to write a module in 
objective-c that will work with apache and this is a list on objective-c and I 
know I wouldn't get much of a reply on the apache lists. And I'm not writing a 
apache module just for a web application, I'm writing it so I can get the 
language of Objective-C to the web easier and better. I am getting closer to 
figuring out how to compile a module in cocoa. I think I can take it from here 
and I will post the first Objective-C module's source here for all to see and 
possibly use.

Thanks for the tips,
Mr. Gecko

On Nov 28, 2009, at 12:21 AM, Jens Alfke wrote:

> You absolutely do not want to write an Apache module to implement a web-app! 
> That's massive overkill, like building a machine shop in your garage instead 
> of just going to Home Depot.
> 
> If you need more performance than the basic CGI interface provides, good ways 
> to go are either SCGI (which will use an Apache module to make a connection 
> to your process and send it requests), or proxying (implement a basic HTTP 
> server in your app and proxy to it from Apache; you can then scale up by 
> running multiple copies of your app and fanning out.)
> 
> This stuff has been done many, many times before; it's just that people don't 
> use Cocoa for it. IMHO it's not the right tool for the job in most cases. 
> Web-apps tend to be written in interpreted languages like Java, Python, PHP, 
> Ruby, etc. About the only developer I know of who does a lot of web 
> development in native code is Google, because as you can imagine they have 
> the world's most horrific scalability problems to deal with. And they only 
> use that when they need to, for core stuff; lots of their apps, like Google 
> Docs, are written in Java.
> 
> In short, you are on the wrong list for discussing the kind of stuff. You 
> need to find a forum about web development, regardless of what language you 
> want to use. And my advice would be to avoid native code unless you have 
> known, measurable performance problems with any interpreted solution.
> 
> —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/archive%40mail-archive.com

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


Inconsistent results from iconForFile

2009-11-27 Thread Sandy McGuffog
Part of my code uses:

[[NSWorkspace sharedWorkspace] iconForFile:path];

For some files, I get a thumbnail of the file, so e.g., for a JPEG, I get a 
miniature of the actual image in the JPEG. But for other files, even in the 
same directory, I get the file type icon, so e.g., for a JPEG, the OS X JPEG 
icon.

All these files show the miniature of the image in Finder.

I've also tried with [NSFileWrapper icon]. Same result.

Can anyone shed light on this?

Thanks,

Sandy___

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: Apache Module

2009-11-27 Thread Jens Alfke

On Nov 27, 2009, at 10:11 PM, Chris Hanson wrote:

> I believe Mac OS X 10.5+ includes the FastCGI Apache module and C library, 
> which are for just this kind of use: Maintaining a pool of CGI-style servers 
> that use Apache to provide an HTTP front-end without the overhead of one 
> fork/exec per HTTP connection.

FastCGI is an extremely nasty protocol. I speak from experience here. FastCGI 
has mostly been abandoned in recent years because it's too intractable to work 
with and no one has been willing to fix the Apache module.

SCGI does exactly the same thing, but is a lot more approachable (and there's 
an Apache module for it, though it might not be pre-installed.)

—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/archive%40mail-archive.com

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


Re: Apache Module

2009-11-27 Thread Jens Alfke
You absolutely do not want to write an Apache module to implement a web-app! 
That's massive overkill, like building a machine shop in your garage instead of 
just going to Home Depot.

If you need more performance than the basic CGI interface provides, good ways 
to go are either SCGI (which will use an Apache module to make a connection to 
your process and send it requests), or proxying (implement a basic HTTP server 
in your app and proxy to it from Apache; you can then scale up by running 
multiple copies of your app and fanning out.)

This stuff has been done many, many times before; it's just that people don't 
use Cocoa for it. IMHO it's not the right tool for the job in most cases. 
Web-apps tend to be written in interpreted languages like Java, Python, PHP, 
Ruby, etc. About the only developer I know of who does a lot of web development 
in native code is Google, because as you can imagine they have the world's most 
horrific scalability problems to deal with. And they only use that when they 
need to, for core stuff; lots of their apps, like Google Docs, are written in 
Java.

In short, you are on the wrong list for discussing the kind of stuff. You need 
to find a forum about web development, regardless of what language you want to 
use. And my advice would be to avoid native code unless you have known, 
measurable performance problems with any interpreted solution.

—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/archive%40mail-archive.com

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


Re: Apache Module

2009-11-27 Thread Chris Hanson

On Nov 27, 2009, at 4:52 PM, Bill Bumgarner  wrote:

Then again, HTTP server <-> backend server is a very well explored  
area of technology that may offer a pre-rolled solution for you.


I believe Mac OS X 10.5+ includes the FastCGI Apache module and C  
library, which are for just this kind of use: Maintaining a pool of  
CGI-style servers that use Apache to provide an HTTP front-end without  
the overhead of one fork/exec per HTTP connection.


  -- 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


Referencing NSData's length in a predicate?

2009-11-27 Thread Dave DeLong
Hi everyone,

I have a Core Data object called "Item".  One of its attributes is a binary 
attribute called "data".  I've constructed a fetch request to retrieve all 
Items based on the length of the data (ex: "data.length <= 1024").  I *know* 
that I have Items with data less than 1KB, yet when I execute this predicate, 
it doesn't seem to be returning anything (nothing shows up in my NSTableView of 
results, while the results of every other fetch request show up just fine).

My Items' data can potentially be very large (in the megabyte range), so the 
fetch request is only fetching small properties (title, date, etc).  Thinking 
this might be causing issues, I changed the request to retrieve all Item 
properties.  However, I still didn't get any results.  I've tried doing sizes 
greater than 1024 (like 1048576 [1 MB] or 1073741824 [1 GB]), but those don't 
return anything either.

What's curious is that I can use data.length in a keypath.  I've bound my 
NSArrayController of Item objects to my UI, and one of the bindings is to show 
the @sum.data.length of the controller's arrangedObjects, and that's 
(apparently) working properly.  However, when I try to use it in a predicate, I 
get nothing.

For example, I have at least one Item that has a data of length 414 (as 
reported by my @sum.data.length binding).  Here's how the following predicates 
work out:

data.length == 414 => returns 0 of 153 items
data.length != 414=> returns 153 of 153 items
data.length < 415 => returns 1 item (size 251B)
data.length <= 414 => returns 1 item (size 251B)
data.length >= 414 => returns 151 of 153 items
data.length > 413 => returns 151 of 153 items

I haven't found anything in the documentation that indicates that this wouldn't 
work, so can you help me see what I'm missing?

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

How can I choose font depending upon Locale.

2009-11-27 Thread Symadept
Hi,

My client has given me a custom TTF font only for English. So my intention
is to load that TTF only for English and for other languages it should
fallback to the available System font.

I am doing the following steps:

1. Registering fonts with my app.
Copying into Resources folder and add to my project.
2. Loading the font with name.

NSMutableDictionary * aTitleAttributes = [[[NSMutableDictionary alloc]
initWithObjectsAndKeys:

   [NSFont fontWithName:CP_FONT_NAME size:[NSFont systemFontSize]],
NSFontAttributeName,

aParagraphStyle, NSParagraphStyleAttributeName,

   nil] autorelease];
my But this results into another problem, since I am loading the fonts in
this way for all the languges, my localization text looks english. Hence I
think I should have some condition like

NSFont *font = nil;
If (currentLocaleIsEnglish()) {
/// font to load my custom TTF
}
Then use [NSFont fontwithName:font ...]

So can anybody help me to realize whatever I am doing is right with
registering the font with App. If so how can I register my font only for
English version. Because for other locales this font is not available then
NSFont::fontWithName will return nil and automatically fallsback to the
SystemFont and hence my locale shall be shown properly.

Otherwise I have to have a condition like what I mentioned above, which is a
crude way of doing. If so how can I write such an API for finding
currentLocale Is English?

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


Re: UIImageView Animation Question

2009-11-27 Thread Matt Neuburg
On Fri, 27 Nov 2009 15:53:30 -0800, David Duncan 
said:
>On Nov 27, 2009, at 2:02 PM, Matt Neuburg wrote:
>
>> It's really another case of a poor choice of terminology, isn't it? (By
>> "another" I am referring to my recent critique on this list of the confusing
>> over-use of the term "key" throughout the animation stuff.) Here we are in a
>> graphics world, so the user must be forgiven for supposing that "context" is
>> asking for a graphics context. If the name-mongers had used "contextInfo" as
>> elsewhere in Cocoa, the purpose of this parameter would have been much more
>> obvious. m.
>
>
>I'm not a name monger by any means, but in this case I would say that since the
type of the parameter is void* implies that there is no relation. If the
parameter had been meant to always be a CGContextRef, then it would have been
typed as such. Similarly, if it was meant to always be an object type, it would
be at least of type id. And of course, its purpose is spelled out clearly from
the documentation :).

All of what you're saying is perfectly true. But what I'm saying is *also*
true. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/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/archive%40mail-archive.com

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


Re: Apache Module

2009-11-27 Thread Greg Guerin

Mr. Gecko wrote:


... and that does not solve my make my server speak things.



CGI that runs /usr/bin/say?

You'll want to rate-limit it, or exclusive-lock it, otherwise it can  
speak many things in parallel.  You can try polyphony/cacaphony now  
with 'say ... &' in Terminal.app.


  -- GG

___

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: Apache Module

2009-11-27 Thread Mr. Gecko
The image is different for each and every person and I can't cache it. The disk 
will already be used to get the php to run which generates the page the image 
is on. I know this may sound like a Captcha, but it's not. I will continue to 
try and write this module and if it works out, then I'll be happy. I'm already 
working on my first step, getting mod_example to compile in xcode.

On Nov 27, 2009, at 7:55 PM, Bill Bumgarner wrote:

> 
> On Nov 27, 2009, at 5:08 PM, Mr. Gecko wrote:
> 
>> My idea was to basically write a module that runs NSTask to start the cocoa 
>> binary and just have a framework to like manage the server information and 
>> talk to the module, by printf I guess, saying like which headers to return 
>> and the data so I can set the content-type to image/png if I wanted to 
>> return a png. Well all I can say is it's really complicated, I guess all I 
>> need is to write a module that runs exec(); and handles outputs until it 
>> quits.
> 
> As soon as you get NSTask into the mix, you are likely going to kill 
> performance [and might as well just use straight CGI, at that point]
> 
> If scalability matters at all, you are going to want the image creation to be 
> handled by something that sticks around long enough to cache and otherwise 
> avoid the cost of repeated startup and disk I/O.
> 
> If there is any text parsing or other transformation between whatever your 
> server or process spews and what is sent back to the client, you are likely 
> going to kill performance, too.
> 
> b.bum
> 

___

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: Apache Module

2009-11-27 Thread Bill Bumgarner

On Nov 27, 2009, at 5:08 PM, Mr. Gecko wrote:

> My idea was to basically write a module that runs NSTask to start the cocoa 
> binary and just have a framework to like manage the server information and 
> talk to the module, by printf I guess, saying like which headers to return 
> and the data so I can set the content-type to image/png if I wanted to return 
> a png. Well all I can say is it's really complicated, I guess all I need is 
> to write a module that runs exec(); and handles outputs until it quits.

As soon as you get NSTask into the mix, you are likely going to kill 
performance [and might as well just use straight CGI, at that point]

If scalability matters at all, you are going to want the image creation to be 
handled by something that sticks around long enough to cache and otherwise 
avoid the cost of repeated startup and disk I/O.

If there is any text parsing or other transformation between whatever your 
server or process spews and what is sent back to the client, you are likely 
going to kill performance, too.

b.bum

___

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: Core Data and +[NSExpression expressionForFunction:...]

2009-11-27 Thread Jerry Krinock

On 2009 Nov 27, at 12:23, Ron Aldrich wrote:

> but I'd very much like to understand why this isn't working.
> 
> On Nov 25, 2009, at 11:34 PM, Alexander Spohr wrote:
> 
>> I am not sure if that works at all. I never fetched using methods that are 
>> not part of the database as a qualifier.

The reason hypothesized by Alexander is indeed the reason.  Core Data fetch 
predicates won't even work with ^transient^ properties.  Your 
-distanceFromLatitude is even less than transient -- it's derived.  In my 
experience, fetching with such a predicate will fail silently.

These limitations are implied, actually somewhat understated, in the following 
document which describes the "features" of the various store types:

http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/CoreData/Articles/cdPersistentStores.html#//apple_ref/doc/uid/TP40002875

If you read between the lines in the section "Fetch Predicates and Sort 
Descriptors", you'll conclude that what you're doing is not going to work.  

Hey, be thankful that did you didn't test with the XML store and plan to "flip 
the switch" to the sqlite store on shipping day.  You would have been very 
disappointed  :))

___

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: Apache Module

2009-11-27 Thread Mr. Gecko
I know about that but for what I need it's extremely hard to do what I need and 
that does not solve my make my server speak things.

On Nov 27, 2009, at 7:37 PM, Alexander Hartner wrote:

> http://www.php.net/manual/en/image.examples-png.php
> 
> Google is your friend. No need to reinvent the wheel.
> 
> Sent from my iPhone
> 
> On 28 Nov 2009, at 01:08, "Mr. Gecko"  wrote:
> 
>> My idea was to basically write a module that runs NSTask to start the cocoa 
>> binary and just have a framework to like manage the server information and 
>> talk to the module, by printf I guess, saying like which headers to return 
>> and the data so I can set the content-type to image/png if I wanted to 
>> return a png. Well all I can say is it's really complicated, I guess all I 
>> need is to write a module that runs exec(); and handles outputs until it 
>> quits.
>> 
>> On Nov 27, 2009, at 6:52 PM, Bill Bumgarner wrote:
>> 
>>> My recommendation would be to continue with this architecture.  Apache 
>>> tends to spawn a bunch of children -- either in the form of processes [old 
>>> school] or threads [new school -- IIRC] -- and you are quickly going to 
>>> find yourself in multi-threading hell if you try to integrate directly with 
>>> Apache.   By running a separate server process, you can choose how and when 
>>> you apply multithreading hell to achieve scalability (if necessary).
>>> 
>>> For your model, the key is to have the most efficient connection between 
>>> client [apache] and server [your image server daemon].   For that, rolling 
>>> your own may be the right answer.  Then again, HTTP server <-> backend 
>>> server is a very well explored area of technology that may offer a 
>>> pre-rolled solution for you.
>>> 
>>> b.bum
>>> 
>> 
>> ___
>> 
>> 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/alex%40j2anywhere.com
>> 
>> This email sent to a...@j2anywhere.com

___

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: Apache Module

2009-11-27 Thread Alexander Hartner

http://www.php.net/manual/en/image.examples-png.php

Google is your friend. No need to reinvent the wheel.

Sent from my iPhone

On 28 Nov 2009, at 01:08, "Mr. Gecko"  wrote:

My idea was to basically write a module that runs NSTask to start  
the cocoa binary and just have a framework to like manage the server  
information and talk to the module, by printf I guess, saying like  
which headers to return and the data so I can set the content-type  
to image/png if I wanted to return a png. Well all I can say is it's  
really complicated, I guess all I need is to write a module that  
runs exec(); and handles outputs until it quits.


On Nov 27, 2009, at 6:52 PM, Bill Bumgarner wrote:

My recommendation would be to continue with this architecture.   
Apache tends to spawn a bunch of children -- either in the form of  
processes [old school] or threads [new school -- IIRC] -- and you  
are quickly going to find yourself in multi-threading hell if you  
try to integrate directly with Apache.   By running a separate  
server process, you can choose how and when you apply  
multithreading hell to achieve scalability (if necessary).


For your model, the key is to have the most efficient connection  
between client [apache] and server [your image server daemon].
For that, rolling your own may be the right answer.  Then again,  
HTTP server <-> backend server is a very well explored area of  
technology that may offer a pre-rolled solution for you.


b.bum



___

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/alex%40j2anywhere.com

This email sent to a...@j2anywhere.com

___

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: Apache Module

2009-11-27 Thread Mr. Gecko
My idea was to basically write a module that runs NSTask to start the cocoa 
binary and just have a framework to like manage the server information and talk 
to the module, by printf I guess, saying like which headers to return and the 
data so I can set the content-type to image/png if I wanted to return a png. 
Well all I can say is it's really complicated, I guess all I need is to write a 
module that runs exec(); and handles outputs until it quits.

On Nov 27, 2009, at 6:52 PM, Bill Bumgarner wrote:

> My recommendation would be to continue with this architecture.  Apache tends 
> to spawn a bunch of children -- either in the form of processes [old school] 
> or threads [new school -- IIRC] -- and you are quickly going to find yourself 
> in multi-threading hell if you try to integrate directly with Apache.   By 
> running a separate server process, you can choose how and when you apply 
> multithreading hell to achieve scalability (if necessary).
> 
> For your model, the key is to have the most efficient connection between 
> client [apache] and server [your image server daemon].   For that, rolling 
> your own may be the right answer.  Then again, HTTP server <-> backend server 
> is a very well explored area of technology that may offer a pre-rolled 
> solution for you.
> 
> b.bum
> 

___

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: Apache Module

2009-11-27 Thread Alexander Hartner

http://httpd.apache.org/docs/1.3/howto/cgi.html

This tutorials covers creating dynamic content in c. Can't be all that  
different fir objective c.


Sent from my iPhone

On 28 Nov 2009, at 00:50, "Mr. Gecko"  wrote:

As I said, I couldn't find any other way to do this advanced stuff  
which I have in mind, like I have an idea of a notification system  
that will use NSSpeechSynthesizer on my server.


On Nov 27, 2009, at 6:46 PM, Alexander Hartner wrote:


Why not use standard plain old cgi to do that?

Sent from my iPhone

On 28 Nov 2009, at 00:30, "Mr. Gecko"  wrote:

Well I'm wanting to be able to write image generators and other  
things that is near impossible to do in php or any other web  
scripting language, also running compiled source is faster then a  
script. My idea is to write a module so I can just use a SDK that  
I will write to make different things in Objective-C. For now I  
have a custom server in cocoa that when you visit it, it returns a  
image based on parameters and this module would really make my  
life easier.


On Nov 27, 2009, at 6:11 PM, Alexander Hartner wrote:


Hi there,

Why would you want such a thing. Objective C compiles to a binary  
which you could integrate with apache using common cgi. However  
these days there are much more mature frameworks available geared  
for the delivery of HTML and other web content.


Maybe I don't understand what you after but to get apache to call  
a binary to produce HTML does not require a new module.


Have fun
Alex

Sent from my iPhone

On 27 Nov 2009, at 23:45, "Mr. Gecko"  wrote:

Hello, I'm working to write an Apache Module that allows you to  
make websites in Objective-C (Foundation/Cocoa) and I need to  
know how I should setup my xcode project. I got the basic idea,  
make a custom target that builds a .so file that has apache  
libraries but is that it? I'm going to try and rewrite the  
mod_example to a Foundation version and if I get it working I  
will post the source code for everyone for more powerful apache  
modules.


Thanks for help and tips,
Mr. Gecko___

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/alex%40j2anywhere.com

This email sent to a...@j2anywhere.com





___

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: Apache Module

2009-11-27 Thread Bill Bumgarner

On Nov 27, 2009, at 4:30 PM, Mr. Gecko wrote:

> Well I'm wanting to be able to write image generators and other things that 
> is near impossible to do in php or any other web scripting language, also 
> running compiled source is faster then a script. My idea is to write a module 
> so I can just use a SDK that I will write to make different things in 
> Objective-C. For now I have a custom server in cocoa that when you visit it, 
> it returns a image based on parameters and this module would really make my 
> life easier.

My recommendation would be to continue with this architecture.  Apache tends to 
spawn a bunch of children -- either in the form of processes [old school] or 
threads [new school -- IIRC] -- and you are quickly going to find yourself in 
multi-threading hell if you try to integrate directly with Apache.   By running 
a separate server process, you can choose how and when you apply multithreading 
hell to achieve scalability (if necessary).

For your model, the key is to have the most efficient connection between client 
[apache] and server [your image server daemon].   For that, rolling your own 
may be the right answer.  Then again, HTTP server <-> backend server is a very 
well explored area of technology that may offer a pre-rolled solution for you.

b.bum

___

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: Apache Module

2009-11-27 Thread Mr. Gecko
As I said, I couldn't find any other way to do this advanced stuff which I have 
in mind, like I have an idea of a notification system that will use 
NSSpeechSynthesizer on my server.

On Nov 27, 2009, at 6:46 PM, Alexander Hartner wrote:

> Why not use standard plain old cgi to do that?
> 
> Sent from my iPhone
> 
> On 28 Nov 2009, at 00:30, "Mr. Gecko"  wrote:
> 
>> Well I'm wanting to be able to write image generators and other things that 
>> is near impossible to do in php or any other web scripting language, also 
>> running compiled source is faster then a script. My idea is to write a 
>> module so I can just use a SDK that I will write to make different things in 
>> Objective-C. For now I have a custom server in cocoa that when you visit it, 
>> it returns a image based on parameters and this module would really make my 
>> life easier.
>> 
>> On Nov 27, 2009, at 6:11 PM, Alexander Hartner wrote:
>> 
>>> Hi there,
>>> 
>>> Why would you want such a thing. Objective C compiles to a binary which you 
>>> could integrate with apache using common cgi. However these days there are 
>>> much more mature frameworks available geared for the delivery of HTML and 
>>> other web content.
>>> 
>>> Maybe I don't understand what you after but to get apache to call a binary 
>>> to produce HTML does not require a new module.
>>> 
>>> Have fun
>>> Alex
>>> 
>>> Sent from my iPhone
>>> 
>>> On 27 Nov 2009, at 23:45, "Mr. Gecko"  wrote:
>>> 
 Hello, I'm working to write an Apache Module that allows you to make 
 websites in Objective-C (Foundation/Cocoa) and I need to know how I should 
 setup my xcode project. I got the basic idea, make a custom target that 
 builds a .so file that has apache libraries but is that it? I'm going to 
 try and rewrite the mod_example to a Foundation version and if I get it 
 working I will post the source code for everyone for more powerful apache 
 modules.
 
 Thanks for help and tips,
 Mr. Gecko___
 
 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/alex%40j2anywhere.com
 
 This email sent to a...@j2anywhere.com
>> 

___

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: Apache Module

2009-11-27 Thread Mr. Gecko
Well I'm wanting to be able to write image generators and other things that is 
near impossible to do in php or any other web scripting language, also running 
compiled source is faster then a script. My idea is to write a module so I can 
just use a SDK that I will write to make different things in Objective-C. For 
now I have a custom server in cocoa that when you visit it, it returns a image 
based on parameters and this module would really make my life easier.

On Nov 27, 2009, at 6:11 PM, Alexander Hartner wrote:

> Hi there,
> 
> Why would you want such a thing. Objective C compiles to a binary which you 
> could integrate with apache using common cgi. However these days there are 
> much more mature frameworks available geared for the delivery of HTML and 
> other web content.
> 
> Maybe I don't understand what you after but to get apache to call a binary to 
> produce HTML does not require a new module.
> 
> Have fun
> Alex
> 
> Sent from my iPhone
> 
> On 27 Nov 2009, at 23:45, "Mr. Gecko"  wrote:
> 
>> Hello, I'm working to write an Apache Module that allows you to make 
>> websites in Objective-C (Foundation/Cocoa) and I need to know how I should 
>> setup my xcode project. I got the basic idea, make a custom target that 
>> builds a .so file that has apache libraries but is that it? I'm going to try 
>> and rewrite the mod_example to a Foundation version and if I get it working 
>> I will post the source code for everyone for more powerful apache modules.
>> 
>> Thanks for help and tips,
>> Mr. Gecko___
>> 
>> 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/alex%40j2anywhere.com
>> 
>> This email sent to a...@j2anywhere.com

___

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


Fwd: Apache Module

2009-11-27 Thread Alexander Hartner

Hi there,

Why would you want such a thing. Objective C compiles to a binary  
which you could integrate with apache using common cgi. However  
these days there are much more mature frameworks available geared  
for the delivery of HTML and other web content.


Maybe I don't understand what you after but to get apache to call a  
binary to produce HTML does not require a new module.


Have fun
Alex

Sent from my iPhone

On 27 Nov 2009, at 23:45, "Mr. Gecko"  wrote:

Hello, I'm working to write an Apache Module that allows you to  
make websites in Objective-C (Foundation/Cocoa) and I need to know  
how I should setup my xcode project. I got the basic idea, make a  
custom target that builds a .so file that has apache libraries but  
is that it? I'm going to try and rewrite the mod_example to a  
Foundation version and if I get it working I will post the source  
code for everyone for more powerful apache modules.


Thanks for help and tips,
Mr. Gecko___

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/alex 
%40j2anywhere.com


This email sent to a...@j2anywhere.com

___

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: UIImageView Animation Question

2009-11-27 Thread David Duncan
On Nov 27, 2009, at 2:02 PM, Matt Neuburg wrote:

> It's really another case of a poor choice of terminology, isn't it? (By
> "another" I am referring to my recent critique on this list of the confusing
> over-use of the term "key" throughout the animation stuff.) Here we are in a
> graphics world, so the user must be forgiven for supposing that "context" is
> asking for a graphics context. If the name-mongers had used "contextInfo" as
> elsewhere in Cocoa, the purpose of this parameter would have been much more
> obvious. m.


I'm not a name monger by any means, but in this case I would say that since the 
type of the parameter is void* implies that there is no relation. If the 
parameter had been meant to always be a CGContextRef, then it would have been 
typed as such. Similarly, if it was meant to always be an object type, it would 
be at least of type id. And of course, its purpose is spelled out clearly from 
the documentation :).
--
David Duncan
Apple DTS Animation and Printing

___

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: dynamic NSPointArray allocation

2009-11-27 Thread Graham Cox

On 28/11/2009, at 10:37 AM, Shane wrote:

>> Why not just accumulate the points directly into NSBezierPath? It can be 
>> thought of as an array of points in a sense. Unless there's a compelling 
>> need to have the points themselves available in addition to the bezier path, 
>> just cut out the middle man (and it's not difficult to retrieve the points 
>> from a bezier path in any case).
> 
> Oops, possible duplication here, apologies ahead of time.
> 
> I liked the idea, but because my window can get resized and therefore,
> I'd have to rescale the points each and every time to fit my borders,
> I'm thinking using a middle man for this and just passing the
> NSPointArray might work better. Unless there's a better way.


Sure there is - you can transform a bezier path using an NSAffineTransform to 
scale it (and displace, rotate it) to wherever you want. You definitely 
shouldn't need to iterate over the points and perform a transformation on them 
yourself, unless you have some non-affine transformation in mind.

You can also set the scale for a view or any graphics context which will 
perform scaling for you.

The two approaches are similar but not identical. The first will transform the 
path itself, so if you  stroke it with, say a 2pt stroke, it will still be a 
2pt stroke on the scaled path. In the second case, the stroke will also be 
scaled.

I'm assuming that you want to draw the path, rather than just have a list of 
points for some other purpose? If not, then perhaps using a bezier path 
wouldn't be the best approach, but if you do intend to draw the path, I'd 
definitely use NSBezierPath.

--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/archive%40mail-archive.com

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


Apache Module

2009-11-27 Thread Mr. Gecko
Hello, I'm working to write an Apache Module that allows you to make websites 
in Objective-C (Foundation/Cocoa) and I need to know how I should setup my 
xcode project. I got the basic idea, make a custom target that builds a .so 
file that has apache libraries but is that it? I'm going to try and rewrite the 
mod_example to a Foundation version and if I get it working I will post the 
source code for everyone for more powerful apache modules.

Thanks for help and tips,
Mr. Gecko___

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: dynamic NSPointArray allocation

2009-11-27 Thread Shane
> Why not just accumulate the points directly into NSBezierPath? It can be 
> thought of as an array of points in a sense. Unless there's a compelling need 
> to have the points themselves available in addition to the bezier path, just 
> cut out the middle man (and it's not difficult to retrieve the points from a 
> bezier path in any case).

Oops, possible duplication here, apologies ahead of time.

I liked the idea, but because my window can get resized and therefore,
I'd have to rescale the points each and every time to fit my borders,
I'm thinking using a middle man for this and just passing the
NSPointArray might work better. Unless there's a better way.
___

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: dynamic NSPointArray allocation

2009-11-27 Thread Graham Cox

On 28/11/2009, at 7:46 AM, Shane wrote:

> I don't know how large my NSPointArray size needs to be so I'd like to
> know how I would dynamically allocate NSPoints to populate an
> NSPointArray? I think I can do it with NSMutableArray, but
> NSBezierPath takes an NSPointArray (which is what my end result is for
> the points) and it just seems cleaner and more efficient if I can stay
> with that instead of converting between point arrays and mutable
> arrays.


Why not just accumulate the points directly into NSBezierPath? It can be 
thought of as an array of points in a sense. Unless there's a compelling need 
to have the points themselves available in addition to the bezier path, just 
cut out the middle man (and it's not difficult to retrieve the points from a 
bezier path in any case).

Use [path lineToPoint:] to append a new point, and [path moveToPoint:] for the 
first point.

--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/archive%40mail-archive.com

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


Re: dynamic NSPointArray allocation

2009-11-27 Thread Shane
>
> The easiest way (and Objective-C-ish way) is to use a NSMutableData object 
> with the NSPointArray as its data. Whenever you want to add points, just 
> resize the NSMutableData object to 'sizeof (NSPoint)' * total number of 
> points, and use '(NSPointArray) [data mutableBytes]' as a pointer to the 
> start of the array.
>


I think I'm understanding this in part ...

// *.h
NSMutableData *pointData;
NSPointArray *points;

// *.m
pointData = [[NSMutableData alloc] init];

...

NSPoint point = NSMakePoint([iters floatValue], [mse floatValue]);
// not sure how to get an NSPoint into NSMutableData?

// here I resize NSMutableData, but this will always only be
// increasing the length by 1.
[pointData increaseLenghtBy:sizeof(NSPoint)];

// and here I assign the data to NSPointArray
points = (NSPoint *) [pointData bytes];

And from here I can pass this NSPointArray around till I get to the
point where I will use this data for my NSBezierPath. Will
NSBezierPath (which takes an NSPointArray) be able to properly read
from 'points' by doing the above?

Am I even going about this correctly?
___

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: UIImageView Animation Question

2009-11-27 Thread Matt Neuburg
On Thu, 26 Nov 2009 22:27:39 -0800, David Duncan 
said:
>The context parameter for beginAnimations:context: is just meant as a token for
you to use should you use the callbacks that let you know about the progress of
the animation. The value is completely arbitrary

It's really another case of a poor choice of terminology, isn't it? (By
"another" I am referring to my recent critique on this list of the confusing
over-use of the term "key" throughout the animation stuff.) Here we are in a
graphics world, so the user must be forgiven for supposing that "context" is
asking for a graphics context. If the name-mongers had used "contextInfo" as
elsewhere in Cocoa, the purpose of this parameter would have been much more
obvious. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/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/archive%40mail-archive.com

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


Re: dynamic NSPointArray allocation

2009-11-27 Thread Quincey Morris
On Nov 27, 2009, at 12:46, Shane wrote:

> I don't know how large my NSPointArray size needs to be so I'd like to
> know how I would dynamically allocate NSPoints to populate an
> NSPointArray? I think I can do it with NSMutableArray, but
> NSBezierPath takes an NSPointArray (which is what my end result is for
> the points) and it just seems cleaner and more efficient if I can stay
> with that instead of converting between point arrays and mutable
> arrays.


The most direct (and C-ish) way is to malloc memory for the NSPointArray and 
realloc it whenever you need to grow its size.

The easiest way (and Objective-C-ish way) is to use a NSMutableData object with 
the NSPointArray as its data. Whenever you want to add points, just resize the 
NSMutableData object to 'sizeof (NSPoint)' * total number of points, and use 
'(NSPointArray) [data mutableBytes]' as a pointer to the start of the array.

(If you use the latter approach, and you're using garbage collection, and you 
assign the '[data mutableBytes]' pointer to a stack variable or pass it as a 
method parameter, make sure you keep the NSMutableData object reference alive 
until you're done with the 'mutableBytes' pointer.)



___

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


dynamic NSPointArray allocation

2009-11-27 Thread Shane
I don't know how large my NSPointArray size needs to be so I'd like to
know how I would dynamically allocate NSPoints to populate an
NSPointArray? I think I can do it with NSMutableArray, but
NSBezierPath takes an NSPointArray (which is what my end result is for
the points) and it just seems cleaner and more efficient if I can stay
with that instead of converting between point arrays and mutable
arrays.
___

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: My try/catch block isn't catching exceptions on 10.6

2009-11-27 Thread Scott Ribe
If one thread reads imminentList while another is modifying it, you can
crash. There are instants during the modification where it will be in an
internally inconsistent state.

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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: My try/catch block isn't catching exceptions on 10.6

2009-11-27 Thread Andrew Farmer
On 27 Nov 2009, at 11:40, Mark Allan wrote:
> Isn't it the case that you only need locks around something if you plan that 
> it will be modified by more than one thread at a time, or if you write to it 
> in another thread and care that any read operation will be predictable?

No, that is not the case. An object that is described as "not thread-safe" may 
enter an inconsistent state while being modified that will cause a crash or 
data corruption if accessed. Moreover, there is no guarantee that accessor 
methods will not modify internal state of an object (to cache results, for 
instance, or to control access to another object).

Short version - if an object is not described as being thread-safe, never try 
to do *anything* with it from multiple threads at a time. Otherwise, you're 
just asking for trouble.___

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: Core Data and +[NSExpression expressionForFunction:...]

2009-11-27 Thread Ron Aldrich
Atze,

The documentation for expressionForFunction: makes a point of stating:

> This expression effectively allows your application to invoke any method on 
> any object it can navigate to at runtime. You must consider the security 
> implications of this type of evaluation.

Which would indicate that there is some way to make this work.  I agree that 
speed would be a problem, but I could address that by adding a bounds check 
into the expression.

At this point, it's becoming academic, because I know that I can solve the 
problem with a bounds check, and post process - but I'd very much like to 
understand why this isn't working.

- Ron
 
On Nov 25, 2009, at 11:34 PM, Alexander Spohr wrote:

> Ron,
> 
> I am not sure if that works at all. I never fetched using methods that are 
> not part of the database as a qualifier. Your code has to be very slow 
> because it would need to fetch all Photos and then call 
> distanceFromLatitude:longitude: on each.
> 
> Why not qualify directly using a bounding rect?
> latitude > inLatitude - 0.1 && latitude < inLatitude + 0.1 &&
> longitude > inLongitude - 0.1 && longitude < inLongitude + 0.1
> The database can figure that out very fast.
> 
>   atze
> 
> 
> 
> Am 26.11.2009 um 02:08 schrieb Ron Aldrich:
> 
>> Hello All,
>> 
>> I'm trying to query a Core Data database which contains geoLocation 
>> information for all of the objects of type "Photo" which are within a 
>> specified distance of a target point, using the following code.
>> 
>> - (NSArray*) photosNearLatitude: (NSNumber*) inLatitude
>> longitude: (NSNumber*) inLongitude
>> {
>> NSExpression *theLHS = [NSExpression expressionForFunction: [NSExpression 
>> expressionForEvaluatedObject]
>>   selectorName: 
>> @"distanceFromLatitude:longitude:"
>>  arguments: [NSArray 
>> arrayWithObjects:
>>  [NSExpression 
>> expressionForConstantValue: inLatitude],
>>  [NSExpression 
>> expressionForConstantValue: inLongitude],
>>  nil]];
>> 
>> NSExpression* theRHS = [NSExpression expressionForConstantValue: [NSNumber 
>> numberWithDouble: 0.1]];
>> 
>> NSPredicate* thePredicate = [NSComparisonPredicate 
>> predicateWithLeftExpression: theLHS
>>
>> rightExpression: theRHS
>>   
>> modifier: NSDirectPredicateModifier
>>   
>> type: NSLessThanOrEqualToPredicateOperatorType
>>
>> options: 0];
>> 
>> NSManagedObjectContext* theManagedObjectContext = [self 
>> managedObjectContext];
>> 
>> NSFetchRequest* theFetch = [[[NSFetchRequest alloc] init] autorelease];
>> theFetch.entity = [NSEntityDescription entityForName: @"Photo"
>>   inManagedObjectContext: 
>> theManagedObjectContext];
>> theFetch.predicate = thePredicate;
>> 
>> NSError* theError = NULL;
>> NSArray* theResults = [theManagedObjectContext executeFetchRequest: theFetch
>>  error: 
>> &theError];
>> 
>> return theResults;
>> }
>> 
>> The "Photo" class has the following selector.
>> 
>> - (NSNumber*) distanceFromLatitude: (NSNumber*) inLatitude
>>longitude: (NSNumber*) inLongitude
>> 
>> My problem is that when I call "executeFetchRequest", an exception occurs:
>> 
>> 2009-11-25 16:55:20.633 Serendipity[8498:a0f] Unsupported function 
>> expression FUNCTION(SELF, "distanceFromLatitude:longitude:" , 
>> 47.712834, -122.225)
>> 
>> -[Photo distanceFromLatitude:longitude:] is never called.
>> 
>> Can anyone suggest what might be going wrong?
>> 
>> - Ron Aldrich
>> 
> 
___

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: NSOutlineView - how to have a default item selected

2009-11-27 Thread Boyd Collier

Dave,

Itai Ferber also suggested this fix, and previously I had tried it to  
no avail.  However, the problem turned out to be where I put these  
lines (and a couple of others) in my code.  After much fiddling, I  
finally got things right!  Thanks for taking time to post the  
suggestion.


Boyd


On Nov 25, 2009, at 3:53 PM, Dave DeLong wrote:


How about this?

NSInteger index = [myOutlineView rowForItem:itemToSelect];
NSIndexSet * indexSet = [NSIndexSet indexSetWithIndex:index];
[myOutlineView selectRowIndexes:indexSet byExtendingSelection:NO];

HTH,

Dave

On Nov 25, 2009, at 4:48 PM, Boyd Collier wrote:

Mario Kušnjer's question reminded me of a question that I've been  
pondering about NSOutlineViews, namely, is there a way to have one  
item on the outline initialized in the selected state when the  
outline is first created?  That is, when the window containing the  
outline is first displayed to the user, what I would like is for  
the first item in my outline to already show as selected.  Seems  
like there should be a simple way of doing this, but if so, I've  
not yet discovered it.  I have a small test project based on code  
that Itai Ferber was kind enough to send me, and I would be more  
than happy to make it available to anyone who would be interested  
in looking at it.


Boyd

___

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/bcollier%40sunstroke.sdsu.edu

This email sent to bcoll...@sunstroke.sdsu.edu


___

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: My try/catch block isn't catching exceptions on 10.6

2009-11-27 Thread Mark Allan


On 27 Nov 2009, at 1:10 am, Dave Keck wrote:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)


After a cursory reading of your code it looks like you're dealing with
a threading issue involving myItemList or imminentList. Your comment
mentions "We don't really care if imminentList changes because the
dictionary object will always be there even if the contents aren't."
Does this mean you're modifying imminentList from one thread while
another is attempting to read from it? If so, you need a lock around
the reads and writes.


Isn't it the case that you only need locks around something if you  
plan that it will be modified by more than one thread at a time, or if  
you write to it in another thread and care that any read operation  
will be predictable?


I *do* have locks around myItemList as this thread (and others) will  
be modifying that array, but not around imminentList as I'll only be  
reading it and I wanted to avoid a situation of over-locking things.   
Two other threads do modify imminentList and I use locking in there to  
safeguard those accesses.  In this thread, if the key *is* in  
imminentList, then that's fine and I don't need to do anything.  If  
it's not, that means either it was never in the list or that it was  
just removed from under my feet, either way I'm not that bothered so I  
take the safe option and add it to myItemList.



On 27 Nov 2009, at 12:22 pm, Jeremy Pereira wrote:
// We don't really care if imminentList changes because the  
dictionary object will always be there even if the contents aren't.


Yes you do.  NsMutableDictionary methods are not thread safe.  If  
you have other threads changing imminentList, while this thread is  
inserting stuff, you'll need locking.


Other threads do change imminentList, but their access to it is  
controlled via an NSLock.  This thread doesn't insert anything into  
imminentList at all, it merely checks for the existence of a  
particular key.  The only thing being inserted into is myItemList, and  
I use NSLocks around anything that accesses that too.


Looking at the code, I don't think there is anything in it that  
could throw an exception that you would want to handle.  sending  
objectToKey: to listToCopyFrom could raise an exception if it has  
become shorter between the loop test and sending the message, but  
that's a programmer error...


... and shouldn't happen because no other thread has access to  
listToCopyFrom.


Sending setObject:forKey: could throw an exception if the NSNumber  
is nil, but that would mean virtual memory exhaustion, what are you  
going to do if you catch an out of memory condition?  So I think  
your try catch block is superfluous in this instance.


The catch block *is* superfluous.  I only added it when I started  
seeing these crashlogs come in as an attempt to pin down what was  
happening.  At least I now know why it catch block wasn't being  
executed!


However, if there was an code that could throw an exception you  
wanted to handle, your block currently leaks an object reference,  
because the exception would bypass [listToCopyFrom release].  I tend  
to use the following idiom:


Yes, I have @finally blocks elsewhere for that reason.  Thanks  
though.  As I say, the try/catch was just something I was trying in a  
development version of my app.


I'll add some locking logic around my reads from imminentList and use  
an enumerator for listToCopyFrom  to see if that makes any difference.


Thanks all for your advice,
Mark

___

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: Conversion of CFSocketCreateWithNative -> NSSocketPort

2009-11-27 Thread Andrew Farmer
On 27 Nov 2009, at 06:48, Michael Ash wrote:
> There's no Cocoa version of this, as far as I know. However,
> CFSocketCopyPeerAddress is just a wrapper around the POSIX function
> getpeername(), so you can just get the native socket from your
> NSSocketPort and then call that.

Or just keep using CFSocketCopyPeerAddress. Using CoreFoundation is not a crime 
- it's just as much a part of OS X as Cocoa is, and it's not going to be 
removed at any point in the foreseeable 
future.___

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: Custom Controls Where to start

2009-11-27 Thread Henry McGilton (Boulevardier)

On Nov 26, 2009, at 4:01 PM, Sandro Noël wrote:

> Thank you Alastair.
> 
> Well it's pretty complicated, This is my third application, the first being 
> Bonjour Mounter, the Second RDP Launcher.
> Others were created but never released. I've always used the OS's controls 
> but now I find myself frustrated 
> with the limits of these controls in terms of looks. I see other application 
> makers producing great looking 
> applications with custom looking views and controls.
> 
> So I want to be able to know where to start and what to think about when I 
> create a control, a view.
> I did venture to read the Doc documentation, there is much there but so much 
> it becomes confusing.
> 
> for example, the look of the segment control does not fit the look that i'd 
> like it to have, i find it's a good enough starting point 
> to create a tab bar, a little like Safari, and add the close tab button and 
> some status information on the right end of the tab.
> along with a scrolling title like on the Apple TV.
> 
> From what I understand, all I would have to do is create my own cell.
> 
> Also, the controls for the HUD panels are missing, there is 
> BWHUDAppKit.framework that does partial of the work witch is amazing.
> but it is not complete, i like to use the CollectionView control, and it hans 
> not been implemented, so i'm off to do it myself.
> there are also table cels missing, i would like to create those too.
> 
> I think that once I've done these I would pretty much be able to create my 
> own out of this world looking controls while preserving HIG intact.
> and it will also give me a better understanding of the underpinnings of cocoa.

You might want to check out BWToolkit:


http://www.brandonwalkin.com/bwtoolkit/___

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: An Array of structs

2009-11-27 Thread Alastair Houghton
On 27 Nov 2009, at 13:30, Jeremy Pereira wrote:

> You can't have non constant elements in struct initialisers, testy is not a 
> constant.  The error message spells out exactly what the issue is.

You *can* have non-constant elements in struct initialisers in C, *but* only in 
a context where there is code that will execute at runtime.

So

  struct foo {
int foo;
  };

  int fn (int anInt) {
struct foo fooArray[] = { { anInt }, { anInt + 1 } };
  }

is quite legitimate, while as you rightly point out

  extern int anInt;

  struct foo {
int foo;
  }

  struct foo fooArray[] = { { anInt }, { anInt + 1 } };

isn't.

In the case of C89/C90, this is an extension provided by GNU C and by some 
other compilers.  It's a formal part of C99, however (see §6.7.8 ¶4 - "All the 
expressions in an initializer for an object that has static storage duration 
shall be constant expressions or string literals.").

In C++, however, the standard says that it's allowed wherever, including for 
objects that have static storage (see §8.5 ¶2), so in C++, both of those pieces 
of code should compile.  There are some caveats, however, in that the order of 
initialisation of objects is not specified; the standard does guarantee that, 
if they haven't yet been initialised dynamically, they'll have been temporarily 
initialised to zeroes (§8.5 ¶6).  Given that there are additionally some issues 
surrounding the implementation of this feature (e.g. it may be necessary to 
call a special function to perform these initialisations on some platforms if 
the module in question doesn't have a conventional main() function, for 
whatever reason), it's probably best to avoid relying on this ability.

Kind regards,

Alastair.

-- 
http://alastairs-place.net



___

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: Conversion of CFSocketCreateWithNative -> NSSocketPort

2009-11-27 Thread Michael Ash
On Fri, Nov 27, 2009 at 6:46 AM, René v Amerongen  wrote:
> Hello,
>
> I' am busy to make an old app up to date and want to use 100% 10.6 cocoa.
> I have +75% percent done, but there is something what I can't figure out.
>
> Network calls are now using NSSocketPort, except a few that uses a fileHandle 
> or fileDescriptor to get an IP address, like:
>
> (NSFileHandle *) fh ... is known and come from another class
> ...
> CFSocketRef socket;
> socket = CFSocketCreateWithNative (kCFAllocatorDefault, [fh fileDescriptor], 
> kCFSocketNoCallBack, NULL, NULL);
> CFDataRef adrData = CFSocketCopyPeerAddress (socket);
> struct sockaddr_in *sock = (struct sockaddr_in *)CFDataGetBytePtr(adrData);
> NSString *address = [NSString stringWithCString:inet_ntoa(sock->sin_addr)]];
> ...
>
> How can I get the IP address from a fileHandle using Cocoa?
> What is the Cocoa alternative of CFSocketCreateWithNative and 
> CFSocketCopyPeerAddress?

There's no Cocoa version of this, as far as I know. However,
CFSocketCopyPeerAddress is just a wrapper around the POSIX function
getpeername(), so you can just get the native socket from your
NSSocketPort and then call that.

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: An Array of structs

2009-11-27 Thread Jeremy Pereira

On 27 Nov 2009, at 11:35, John Love wrote:
> 
> I get "Initializer element is not constant. This pertains to the NSString* 
> because if I directly substitute the following, no compile error happens:
> YearAmt gTest[] = {{@"testy", 10}
> 
> What fundamental pertaining to C or C++ am I not getting?


You can't have non constant elements in struct initialisers, testy is not a 
constant.  The error message spells out exactly what the issue is.

This is not, by the way, an NSString specific issue.  The following gives the 
same error

typedef struct Foo
{
int foo;
} Foo;
int anInt = 6;
Foo fooArray[] = {{ anInt }};

Use of the "const" keyword doesn't help.


> 
> 
> John Love
> Touch the Future! Teach!
> 
> 
> 
> ___
> 
> 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/adc%40jeremyp.net
> 
> This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

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: An Array of structs

2009-11-27 Thread Graham Cox

On 27/11/2009, at 10:35 PM, John Love wrote:

> NSString *testy = @"testy";
> YearAmt gTest[] = {{testy, 10}  /*, + others */};
> 
> I get "Initializer element is not constant. This pertains to the NSString* 
> because if I directly substitute the following, no compile error happens:
> YearAmt gTest[] = {{@"testy", 10}
> 
> What fundamental pertaining to C or C++ am I not getting?


The error tells you - the initialiser is not constant.

Sure, it's constant in the first line, but 'testy' is a variable, so you are 
trying to use a variable as a constant initializer in the second line. That 
isn't allowed.

If you think about how constant initializers in C actually work, at the machine 
code/assembler level, it should be clear why it isn't allowed.

--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/archive%40mail-archive.com

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


Mount afp volume

2009-11-27 Thread gMail.com
Hi,
I use to mount a volume with the old API
FSMountServerVolumeSync
and it works well. My question is, should I use a Cocoa version of this API?
If so, which one?

Also, in my "very old" code, before I call this API, I use to Ping the host.
I can't recall why I Ping the host before this calling
FSMountServerVolumeSync but I suppose I did so because this API, in case of
error, hanged or crashed... cannot really recall why. The problem is that
PingHost on a particular host today returns an error, and it shouldn't,
while this API returns noErr. So I would like to eliminate PingHost from my
code. Am I doing right?

The best should be a safe Cocoa API. Do you know an API which works with
afp, webdav, smb, local volumes and dmg...?


--
Leonardo


___

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: My try/catch block isn't catching exceptions on 10.6

2009-11-27 Thread Jeremy Pereira

On 26 Nov 2009, at 23:51, Mark Allan wrote:

> 
> 
> Exception Type:  EXC_BAD_ACCESS (SIGBUS)
> Exception Codes: KERN_PROTECTION_FAILURE at 0x0010
> Crashed Thread:  3

You can't catch that with an Objective C exception handler.  It's a Unix bus 
error.  Probably some pointer has changed under your code. 

>   // We don't really care if imminentList changes because the dictionary 
> object will always be there even if the contents aren't.

Yes you do.  NsMutableDictionary methods are not thread safe.  If you have 
other threads changing imminentList, while this thread is inserting stuff, 
you'll need locking.


>   [self getLock4itemList];
>   @try{
>   [listToCopyFrom retain];
>   int counter = 0;
>   for (counter=0; counter < [listToCopyFrom count]; counter++) {
>   NSString *theKey = [listToCopyFrom 
> objectAtIndex:counter];
>   if(theKey != nil){
>   if ( ([myItemList objectForKey:theKey] == nil) 
> && ([imminentList objectForKey:theKey] == nil)) {
>   [myItemList setObject:[NSNumber 
> numberWithLongLong:-1] forKey:theKey];
>   }
>   else{
>   //theKey already exists, don't add it 
> again
>   }
>   }
>   }
>   [listToCopyFrom removeAllObjects];  // remove all the 
> objects so we don't see them again next time around
>   [listToCopyFrom release];   // counteracts 
> the retain at start of this method
>   }
>   @catch (NSException *e) {
>   NSLog(@"Splat! Reason: %@", [e reason]);
>   }
>   [self releaseLock4itemList];
> }

Looking at the above code, I don't think there is anything in it that could 
throw an exception that you would want to handle.  sending objectToKey: to 
listToCopyFrom could raise an exception if it has become shorter between the 
loop test and sending the message, but that's a programmer error.  Sending 
setObject:forKey: could throw an exception if the NSNumber is nil, but that 
would mean virtual memory exhaustion, what are you going to do if you catch an 
out of memory condition?  So I think your try catch block is superfluous in 
this instance.

However, if there was an code that could throw an exception you wanted to 
handle, your block currently leaks an object reference, because the exception 
would bypass [listToCopyFrom release].  I tend to use the following idiom:

[anObject retain];
@try
{
// do stuff that might throw an Objective C exception
}
@catch (NSException* e)
{
// handle the exception
}
@finally
{
[anObject release];
}


> 
> Thanks
> Mark
> 
> ___
> 
> 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/adc%40jeremyp.net
> 
> This email sent to a...@jeremyp.net


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

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


Conversion of CFSocketCreateWithNative -> NSSocketPort

2009-11-27 Thread René v Amerongen
Hello,

I' am busy to make an old app up to date and want to use 100% 10.6 cocoa.
I have +75% percent done, but there is something what I can't figure out.

Network calls are now using NSSocketPort, except a few that uses a fileHandle 
or fileDescriptor to get an IP address, like:

(NSFileHandle *) fh ... is known and come from another class
...
CFSocketRef socket;
socket = CFSocketCreateWithNative (kCFAllocatorDefault, [fh fileDescriptor], 
kCFSocketNoCallBack, NULL, NULL);
CFDataRef adrData = CFSocketCopyPeerAddress (socket);
struct sockaddr_in *sock = (struct sockaddr_in *)CFDataGetBytePtr(adrData);
NSString *address = [NSString stringWithCString:inet_ntoa(sock->sin_addr)]];
...

How can I get the IP address from a fileHandle using Cocoa?
What is the Cocoa alternative of CFSocketCreateWithNative and 
CFSocketCopyPeerAddress?

Your help is very appreciated.

Thanks in advance


___

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


An Array of structs

2009-11-27 Thread John Love
In my .h file, I have:

typedef struct YearAmt {
NSString  *year;
int   amount;
} YearAmt;

extern NSString *testy;
extern YearAmt gTest[];

In the corresponding .m file:

NSString *testy = @"testy";
YearAmt gTest[] = {{testy, 10}  /*, + others */};

I get "Initializer element is not constant. This pertains to the NSString* 
because if I directly substitute the following, no compile error happens:
YearAmt gTest[] = {{@"testy", 10}

What fundamental pertaining to C or C++ am I not getting?


John Love
Touch the Future! Teach!



___

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


Invoking ImageKit effects panel

2009-11-27 Thread Florian Soenens

Hi list,

i googled this but found nothing relevant.
Is it possible to invoke or access the effects view of the  
[IKImageEditPanel sharedImageEditPanel]?


What i would like to do is add this effcets view to my own custom  
view, in other words i don't want it to be in its own HUD panel.

Is this possible without breaking to many rules?

Kind regards,

- Florian

Looking for Web-to-Print Solutions?
Visit our website :   http://www.vit2print.com


This e-mail, and any attachments thereto, is intended only for use by the 
addressee(s) named herein and may contain legally privileged and/or 
confidential information and/or information protected by intellectual property 
rights.
If you are not the intended recipient, please note that any review, 
dissemination, disclosure, alteration, printing, copying or transmission of 
this e-mail and/or any file transmitted with it, is strictly prohibited and may 
be unlawful.
If you have received this e-mail by mistake, please immediately notify the 
sender and permanently delete the original as well as any copy of any e-mail 
and any printout thereof.
We may monitor e-mail to and from our network.

NSS nv Tieltstraat 167 8740 Pittem Belgium 
___


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: My try/catch block isn't catching exceptions on 10.6

2009-11-27 Thread Matt Gough

On 27 Nov 2009, at 01:08:28, Graham Cox wrote:

> Does Objective C support multiple catch blocks, like C++? In other words you 
> could do:
> 
> @try
> {
> ...
> }
> @catch( NSException* e)
> {
>  // deal with NSException
> }
> @catch(...)
> {
>  // deal with any other sort of exception
> }

The equivalent in Obj-c would be :

@try
{
...
}
@catch( NSException* e)
{
 // deal with NSException
}
@catch(id ue)
{
 // deal with any other sort of exception
}


___

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


Getting the path to an application with a launchDaemon

2009-11-27 Thread Zephyroth Akash

Hi,

I'm actually creating a daemon which then runs in root context and I  
can't get the path to an application.


The command: [[NSWorkspace sharedWorkspace]  
absolutePathForAppBundleIdentifier:@"com.myCompany.myApp"]; returns  
NULL but returns the path to my application bundle correctly if used  
as a user.


If I launch my application as a user and tells the daemon to list the  
launched applications then my application is listed.


I don't understand ...

Can someone point me in the right direction ?



___

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