Base64 encoding of NSImage

2012-07-01 Thread Alexander Hartner
I am looking at available option to send an NSImage to a webserver. I came 
across gSoap however its licensing model makes it not suitable. Using REST / 
JSON seems like an easy option however NSDATA does not seem to be supported by 
the JSON Serialiser. The one remaining option I considered was to encode the 
image myself to base64 before including in the JSON request. This could work 
quite nicely, however there doesn't seem to be a standard method for base64 
encoding. 

Any suggestion on how to best achieve this.

Kind regards
Alex
___

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

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

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

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


Re: Base64 encoding of NSImage

2012-07-01 Thread Richard Altenburg (Brainchild)
I think the answers given here will help you out:

http://stackoverflow.com/questions/392464/any-base64-library-on-iphone-sdk


[[[Brainchild alloc] initWithName:@Richard Altenburg] saysBestRegards];

Op 1 jul. 2012, om 17:23 heeft Alexander Hartner het volgende geschreven:

 I am looking at available option to send an NSImage to a webserver. I came 
 across gSoap however its licensing model makes it not suitable. Using REST / 
 JSON seems like an easy option however NSDATA does not seem to be supported 
 by the JSON Serialiser. The one remaining option I considered was to encode 
 the image myself to base64 before including in the JSON request. This could 
 work quite nicely, however there doesn't seem to be a standard method for 
 base64 encoding. 
 
 Any suggestion on how to best achieve this.
 
 Kind regards
 Alex
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40brainchild.nl
 
 This email sent to cocoa-...@brainchild.nl


___

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

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

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

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


Re: Base64 encoding of NSImage

2012-07-01 Thread Alex Zavatone
I think that only cocoa collections can be supported by the JSON serializer.

Even CLLocations aren't supported since they consist of structs.

On Jul 1, 2012, at 11:23 AM, Alexander Hartner wrote:

 I am looking at available option to send an NSImage to a webserver. I came 
 across gSoap however its licensing model makes it not suitable. Using REST / 
 JSON seems like an easy option however NSDATA does not seem to be supported 
 by the JSON Serialiser. The one remaining option I considered was to encode 
 the image myself to base64 before including in the JSON request. This could 
 work quite nicely, however there doesn't seem to be a standard method for 
 base64 encoding. 
 
 Any suggestion on how to best achieve this.
 
 Kind regards
 Alex
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
 
 This email sent to z...@mac.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Base64 encoding of NSImage

2012-07-01 Thread Tom Hohensee
Try here.  it is a category for nsdata in this post.
http://www.thohensee.com/?page_id=435

Tom

Sent from my iPhone

On Jul 1, 2012, at 10:26 AM, Alexander Hartner a...@j2anywhere.com wrote:

I am looking at available option to send an NSImage to a webserver. I came
across gSoap however its licensing model makes it not suitable. Using REST
/ JSON seems like an easy option however NSDATA does not seem to be
supported by the JSON Serialiser. The one remaining option I considered was
to encode the image myself to base64 before including in the JSON request.
This could work quite nicely, however there doesn't seem to be a standard
method for base64 encoding.

Any suggestion on how to best achieve this.

Kind regards
Alex
___

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

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

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/tom.hohensee%40gmail.com

This email sent to tom.hohen...@gmail.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Base64 encoding of NSImage

2012-07-01 Thread Richard Altenburg (Brainchild)
If you want to be sure which one works for you, it is probably best to read how 
Base64 encoding actually works, maybe you find out you can just as easily roll 
your own solution. Especially on a fast Mac desktop, it would not have to be 
the worlds' most efficient solution, it will be fast anyways, and always faster 
than the web server you are uploading to.

This might help:

http://email.about.com/cs/standards/a/base64_encoding.htm


[[[Brainchild alloc] initWithName:@Richard Altenburg] saysBestRegards];

Op 1 jul. 2012, om 17:46 heeft Alexander Hartner het volgende geschreven:

 There seem to be a number of options listed on the suggested solution. Hard 
 to see which one is best.

___

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

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

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

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


Re: Base64 encoding of NSImage

2012-07-01 Thread Kyle Sluder
On Sun, Jul 1, 2012, at 11:23 PM, Alexander Hartner wrote:
 I am looking at available option to send an NSImage to a webserver. I
 came across gSoap however its licensing model makes it not suitable.
 Using REST / JSON seems like an easy option however NSDATA does not seem
 to be supported by the JSON Serialiser. The one remaining option I
 considered was to encode the image myself to base64 before including in
 the JSON request. This could work quite nicely, however there doesn't
 seem to be a standard method for base64 encoding. 
 
 Any suggestion on how to best achieve this.

If you're in control over both the client and server, I'd suggest
avoiding sending the image data over JSON. You're going to seriously
inflate the file size by base64-encoding it, and for what purpose?

You can be REST without using JSON. It would be much more efficient if
you could just issue a PUT at a certain URL to upload the image data.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Base64 encoding of NSImage

2012-07-01 Thread Jim Zajkowski
On Sun, Jul 1, 2012 at 1:05 PM, Kyle Sluder k...@ksluder.com wrote:

 On Sun, Jul 1, 2012, at 11:23 PM, Alexander Hartner wrote:
 I am looking at available option to send an NSImage to a webserver.

 If you're in control over both the client and server, I'd suggest
 avoiding sending the image data over JSON. You're going to seriously
 inflate the file size by base64-encoding it, and for what purpose?

 You can be REST without using JSON. It would be much more efficient if
 you could just issue a PUT at a certain URL to upload the image data.

I completely agree - don't encode it unless you're sure you really
need that, such as if your webserver were a VAX and didn't understand
8 bit character encodings.  You're going to balloon the resident
memory size of the app, possibly dramatically if you're talking
arbitrary images.

--Jim
___

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

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

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

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


Re: Base64 encoding of NSImage

2012-07-01 Thread Jens Alfke

On Jul 1, 2012, at 8:23 AM, Alexander Hartner wrote:

 I am looking at available option to send an NSImage to a web server.

The simplest way would jut be to PUT the raw JPEG/PNG/whatever data to a URL on 
the server. No need to encode it.

 I came across gSoap however its licensing model makes it not suitable.

Plus, using SOAP for this would be like using an elaborate rickety Rube 
Goldberg device to swat a fly ;-)

 Using REST / JSON seems like an easy option however NSDATA does not seem to 
 be supported by the JSON Serialiser.

Yes, JSON doesn't support binary data, and the serializer doesn't do any magic 
type transformations for you.

It's not a good idea to transmit base64-encoded data anyway, if you can 
possibly avoid it, as it'll make it ⅓ larger.

—Jens

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Base64 encoding of NSImage

2012-07-01 Thread Jens Alfke

On Jul 1, 2012, at 9:33 AM, Richard Altenburg (Brainchild) wrote:

 If you want to be sure which one works for you, it is probably best to read 
 how Base64 encoding actually works, maybe you find out you can just as easily 
 roll your own solution. Especially on a fast Mac desktop, it would not have 
 to be the worlds' most efficient solution, it will be fast anyways, and 
 always faster than the web server you are uploading to.

Bad idea. You've now added some brand new bit-twiddling code to your app, and 
now you have to test it. Does it handle all lengths of data (there are 3 
different cases, IIRC)? Does it work in big-endian and little-endian? Does it 
work in 64-bit? Does it work if the data is empty or less than 3 bytes long? If 
you've written a decoder, does it handle embedded line-breaks? Does it fail 
gracefully if the input is incorrect? Does it parse all lengths of input?

You get the idea. It's always better to use an already-tested library than to 
roll your own, if it's feasible. This is especially true of code that might be 
parsing untrusted input data (such as a base64 decoder) since bugs in that code 
can often be exploited as attacks.

[I'm aware that the OP doesn't need a decoder for this purpose; but I'm talking 
about the more general issues.]

—Jens

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


How to copy class interface and implementation without connections to .xib file

2012-07-01 Thread Richard Altenburg (Brainchild)
(You may reply in Caps Lock if this question is too noobish for this list)

I wrote an experimental project for Mac OS X. It uses a custom NSView and some 
user interface controls connected to the view's class in Interface Builder.

I want to do about the same project for iOS, so I started a new project in 
Xcode 4.3.3 and created a new class which will be a custom UIView. I copied 
most of the code from the Mac OS X version into the interface and 
implementation of the new class in the new project. Unfortunately the 
connections with the .xib from the other project are still there, which is 
obviously not what I want. I just want to connect the IBOutlets and IBActions 
to the .xib in my new iOS project.

What did I do wrong? And how did all those books I read not make me smart 
enough to figure this out on my own? I must be getting old...


[[[Brainchild alloc] initWithName:@Richard Altenburg] saysBestRegards];
___

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

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

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

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


Re: Base64 encoding of NSImage

2012-07-01 Thread David Riggle
This is what I use. Short and sweet.

@implementation NSData (Base64)

- (NSData *)dataWithBase64Encoding
{
CFDataRef retval = NULL;
SecTransformRef encodeTrans = 
SecEncodeTransformCreate(kSecBase64Encoding, NULL);
if (encodeTrans != NULL) {
if (SecTransformSetAttribute(encodeTrans, 
kSecTransformInputAttributeName, (__bridge CFDataRef)self, NULL))
retval = SecTransformExecute(encodeTrans, NULL);
CFRelease(encodeTrans);
}
return CFBridgingRelease(retval);
}

- (NSData *)dataFromBase64Decoding
{
CFDataRef retval = NULL;
SecTransformRef decodeTrans = 
SecDecodeTransformCreate(kSecBase64Encoding, NULL);
if (decodeTrans != NULL) {
if (SecTransformSetAttribute(decodeTrans, 
kSecTransformInputAttributeName, (__bridge CFDataRef)self, NULL))
retval = SecTransformExecute(decodeTrans, NULL);
CFRelease(decodeTrans);
}
return CFBridgingRelease(retval);
}

@end

___

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

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

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

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


Re: How to copy class interface and implementation without connections to .xib file

2012-07-01 Thread Charles Srstka
On Jul 1, 2012, at 1:39 PM, Richard Altenburg (Brainchild) wrote:

 Unfortunately the connections with the .xib from the other project are still 
 there, which is obviously not what I want. 

I’m not sure I understand what you mean by this. Did you copy over the .xib 
from the other project? If so, of course it will contain all the connections 
from the old .xib, since it’s the same .xib. Just set up a new .xib file, or 
modify the old one to remove everything that doesn’t need to be there.

Charles

___

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

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

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

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

Re: Base64 encoding of NSImage

2012-07-01 Thread Jens Alfke

On Jul 1, 2012, at 12:16 PM, David Riggle wrote:

 This is what I use. Short and sweet.

10.7-only, though. (And not available on iOS.)

—Jens
___

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

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

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

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

Re: How to copy class interface and implementation without connections to .xib file

2012-07-01 Thread Richard Altenburg (Brainchild)
Thanks for your thoughts, Charles.

No, I did not copy the .xib to a new project.

I created a new project for iOS wit one view, and created a new class in it 
that is to be a subclass of UIView which will contain my drawing code in 
drawRect. I copied code from the old project over into the new project, into 
the .h and .m files of the new class. It immediately showed that the outlets 
and actions were connected, and on inspection they were connected to the .xib 
in the old project. I connected them to my new .xib in my new project, but how 
on earth are old ones copied over to a new project is beyond me at this moment.

[[[Brainchild alloc] initWithName:@Richard Altenburg] saysBestRegards];

Op 1 jul. 2012, om 21:21 heeft Charles Srstka het volgende geschreven:

 ’m not sure I understand what you mean by this. Did you copy over the .xib 
 from the other project? If so, of course it will contain all the connections 
 from the old .xib, since it’s the same .xib. Just set up a new .xib file, or 
 modify the old one to remove everything that doesn’t need to be there.

___

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

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

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

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

Re: How to copy class interface and implementation without connections to .xib file

2012-07-01 Thread Jens Alfke

On Jul 1, 2012, at 1:54 PM, Richard Altenburg (Brainchild) wrote:

 It immediately showed that the outlets and actions were connected, and on 
 inspection they were connected to the .xib in the old project.

Um, what _exactly_ did it show? There's no way for files in different projects 
to have relations to each other like that.

—Jens
___

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

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

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

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

Re: How to copy class interface and implementation without connections to .xib file

2012-07-01 Thread Andy Lee
On Jul 1, 2012, at 4:54 PM, Richard Altenburg (Brainchild) wrote:
 Thanks for your thoughts, Charles.
 
 No, I did not copy the .xib to a new project.
 
 I created a new project for iOS wit one view, and created a new class in it 
 that is to be a subclass of UIView which will contain my drawing code in 
 drawRect. I copied code from the old project over into the new project, into 
 the .h and .m files of the new class. It immediately showed that the outlets 
 and actions were connected, and on inspection they were connected to the .xib 
 in the old project. I connected them to my new .xib in my new project, but 
 how on earth are old ones copied over to a new project is beyond me at this 
 moment.

At least once I've started a new project and within the new window a file was 
open that belonged to a previously opened project. I wonder if this is what 
happened to you, and the xib file you were looking at was not the xib file in 
your new project.

If you Command-click the file icon in the window's title bar, you can see the 
full path of the file you are looking at. If the path goes to the old project, 
close it with File  Close YourFileName.xib. The keyboard equivalent is 
Control-Command-W. You might even want to close *all* files that are open in 
that window by holding down that key until the window says No Editor. Closing 
the project window and reopening might help -- I didn't think to try that.

Then click on the xib as listed on the left, in the file navigator pane. *That* 
xib, the correct one, shouldn't have any mysterious connections. The only 
connected outlets should be any that are automatically created when you create 
certain kinds of nib, e.g., from a window controller to a window.

--Andy

___

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

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

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

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


opening file without an extension

2012-07-01 Thread Todd Heberlein
I have an NSDocument subclass, and I want to open a data file that has no file 
extension. (It is BSM audit data, and there is no standard extension).

The application is sandboxed.

When the open panel pops up, all the regular files are greyed out.  Is there a 
way to let Powerbox (??) let the user select any file?

Thanks,

Todd

___

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

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

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

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


Re: opening file without an extension

2012-07-01 Thread Todd Heberlein

On Jul 1, 2012, at 8:19 PM, Charles Srstka wrote:

 Does putting an asterisk (*) in the Extensions field for your document type 
 not work in the sandbox?

Excellent!  Yes it did.

Thanks.

Todd

___

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

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

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

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