Appropriate dealloc and finalize actions

2009-10-11 Thread Karolis Ramanauskas
Good day, everyone,

The situation is simple, I have two instances of the same class (MyClass).
This class has a connection instance variable and a declared property for
that variable:

@property (readwrite, assign) MyClass * connection;

So basically an object has a reference to another object of the same class.
Whenever I remove a one of these objects I check if self.connection is not
nil in a dealloc method and in that case I set other object's connection to
nil to make sure it will not point to a soon to be deallocated instance.

This is my dealloc method:

- (void)dealloc {

if (self.connection) {

self.connection.connection = nil;

}

[super dealloc];

}

All works well with no leaks, etc. However I wanted to make this GC
compatible and decided to include a finalize method with the same
expression. However from what I read in here:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcFinalize.html
this is discouraged. Am I misunderstanding what is being said? The
description of dealloc method doesn't seem to have the same language
associated with it:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.htm
l

Thanks for any insight into this,
Karolis
___

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: A question involving properties

2009-10-11 Thread Karolis Ramanauskas
OK, perhaps I am misunderstanding you, but if you are simply trying to set
the label of the NSTextField you may wanna do this. You do not need to
allocate NSTextField programmatically, it will be loaded automatically.

@interface TestAppDelegate : NSObject  {

NSTextField * _textField;

}


@property (readonly) IBOutlet NSTextField * _textField;


@end


---


@implementation TestAppDelegate


@synthesize _textField;


- (void)awakeFromNib {

 [self._textField setStringValue:@"Hello!"];

 }


@end


I assume you have placed a label in your window and connected it to an
IBOutlet in Interface builder. As you can see I set up _textField as a
readonly property because we don't want to change the NSTextField object,
just set its property "stringValue".

Hopefully that's what you meant. Otherwise perhaps someone else will offer a
better solution...

Karolis

On Sun, Oct 11, 2009 at 4:11 PM, Michael de Haan  wrote:

> May I indulge the group.
>
> In doing the Hillegass challenge of Chapter 18 ( creating a doc based app
> to draw ovals), detoured to get a deeper understanding to Apples Sketch-112,
> which in turn lead to properties and ivars, which lead to this little demo
> app to give me some more insight into how properties and ivars worked.  The
> problem I have is that I cannot set a label programmaticallyand am not
> sure if this is related to my understanding of properties, or my
> understanding of the workings of an NSTExtField.
> ( I did a search of this site, tried, "validateEditing" but still could not
> prevail. )
>
>
> Basically, a non-doc app, with an NSTextField ( whose initial title is
> "label"), an AppController with an IBOutlet ( textField), and with
> AppController's outlet to NSTextField's control connection established in
> the nib.
>
> The relevant code in AppController.h thus.
>
>
>
> @interface AppController : NSObject {
>
>NSTextField * _textField;
>
> }
>
> @property (readwrite, retain) IBOutlet NSTextField *textField;
>
>
> The accessors like this. ( I know that I could have used @synthesize) but I
> wanted to see what was happening in the code.
>
>
> - (NSTextField*) textField
> {
>METHOD_LOG;// << A macro which reveals method's name, and the object
> (self) >>
>NSLog(@"%@", _textField);
>return _textField;
> }
>
> - (void) setTextField: (NSTextField*) t
> {
>METHOD_LOG;
>if ( _textField == t)
>return;
>[_textField release];
>[t retain];
>_textField = t;
>NSLog(@"The value of TextField \"_textField\" is: %@",[_textField
> stringValue]);
>
>// this line a test to see if "validateEditing" works
>
>[_textField validateEditing];  // does not effect outcome
>
> }
>
>
> and finally, in awakeFromNib, this;
>
>
>METHOD_LOG;
> NSColor * g = [ NSColor greenColor];
> NSString *s = @"FooBar";
> NSTextField *f = [[NSTextField alloc]init];
> [f setBackgroundColor:g];
> [f setStringValue:s];
> NSLog(@"The value of TextField \"f\" is: %@",[f stringValue]);
> [self setTextField: f];
>[f release];
>
>
> My output is this: (which includes a warning, which is probably relevant,
> but I have not been able to find much on it);
>
>
>
>  MethodName: setTextField: "self" = 
> The value of TextField "_textField" is: label
> MethodName: awakeFromNib "self" = 
> The value of TextField "f" is: FooBar
> MethodName: setTextField: "self" = 
> The value of TextField "_textField" is: FooBar
>  __CFServiceControllerBeginPBSLoadForLocalizations timed out while talking
> to pbs
>
>
> So, from my reading of ivars, properties and outlets, it seems that Apple
> now recommends that the properties (not the ivars ) be exposed, which I have
> tried to do. Also, from the output in the console, it seems as if the outlet
> is set, but then reverts back to the word "label". Some insight would be
> appreciated. (It might very well be that this involves something that is yet
> to be covered, and if so, I will move on. But, just wish to know if this is
> something obvious that I have missed).
> Thanks as always.
> ___
>
> 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/karolisr%40gmail.com
>
> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@ma

Re: A question involving properties

2009-10-11 Thread Karolis Ramanauskas
Cool, I'm quite a beginner myself, so this may be not quite correct...
When you set up your user interface using interface builder and when the
application launches the window it automatically allocates and initializes
all the objects you placed on the window. *I never tried to replace those
objects, nor did I find it necessary.* You simply connect that object in IB
to your IBOutlet so you have a *reference* in your code to access that UI
object. Also I assume, since you did NOT alloc init the original
NSTextField, you can't just ask it to be released. Other objects are still
referencing it. I just assume that the objects I place using IB are readonly
for me. I can change their properties but not the objects themselves... I'm
sure someone will correct me if I'm wrong.

If, however you wanted to do all UI manually, you would have to worry about
initializing UI objects yourself, you wouldn't drag then onto window in IB.
You would have to manually include them in the window, put them at certain
coordinates, etc.

I think your exercise obscured your goal too much. Instance variables are
simply any data that your object may need. Properties simply add accessor
methods to those ivars automatically and make your class KVC/KVO compliant
for those variables. Try playing with simpler ivars, integers, floats,
strings. Try setting and accessing them from other classes, etc. You'll get
a hang of it.

Regards,
Karolis

On Sun, Oct 11, 2009 at 4:50 PM, Michael de Haan  wrote:

>
> On Oct 11, 2009, at 2:35 PM, Karolis Ramanauskas wrote:
>
>  OK, perhaps I am misunderstanding you, but if you are simply trying to set
>> the label of the NSTextField you may wanna do this.
>>
>
>
> Well...what I was **really** trying to do was get my head around using
> properties/ivars correctly  :-)  But, of course, your solution worked
> immediately! So, just for completeness, the reason my approach did not work
> was ?
>
> 1)one cannot simply assign a new object to a control...it's much more
> involved than this
>
> 2) something else?
>
> Thanks again.
>
>
>
>>
> ___
>
> 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/karolisr%40gmail.com
>
> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Appropriate dealloc and finalize actions

2009-10-11 Thread Karolis Ramanauskas
>
> If you want to do something that doesn't break encapsulation, then you
> should simply release the one ivar connection.  That will let the receiving
> object perform its own actions, by itself, on its own behalf, as appropriate
> to its own affairs.


Thanks, however, I do not see how to accomplish my purpose. I'm confused.
Help ;)

I have object1 that has a connection to object2, (object1.connection =
object2). And at the same time object2.connection = object1:

O1 -> O2
O2 -> O1

If one of these objects gets deallocated how should I make sure the other
object is not pointing to the now deallocated object without doing what I
did:

- (void)dealloc {

if (self.connection) {

self.connection.connection = nil;

}

[super dealloc];

}

Thanks

On Sun, Oct 11, 2009 at 6:11 PM, Greg Guerin  wrote:

> Karolis Ramanauskas wrote:
>
>  - (void)dealloc {
>>
>>if (self.connection) {
>>
>>self.connection.connection = nil;
>>
>>}
>>
>>[super dealloc];
>> }
>>
>
>
> Why would you do this?  You're making one object responsible for the
> internals of another object.  This is a bad idea.  It breaks the individual
> encapsulation of each object.
>
> One of the cardinal points of good object-oriented design is that an
> object's responsibilities are circumscribed.  It should manage itself and
> the things it directly references, nothing else.  For any objects it DOES
> reference, each of those objects also has its own responsibilities, and so
> on recursively.  Objects shouldn't poke their noses into another object's
> business.
>
> If you want to do something that doesn't break encapsulation, then you
> should simply release the one ivar connection.  That will let the receiving
> object perform its own actions, by itself, on its own behalf, as appropriate
> to its own affairs.
>
>  -- 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: Appropriate dealloc and finalize actions

2009-10-12 Thread Karolis Ramanauskas
Thanks, Kai, Greg, Jens,

> It's generally a bad idea to have two objects each retain the other. It
> produces a reference loop, which means neither object can be deallocated
> without manually releasing each side of the relationship.


As was stated in my original email these are all weak references:

@property (readwrite, assign) MyClass * connection;

I am not retaining the other object. In fact I couldn't really do it because
I'm pointing to the object of the SAME class.

MyClass 1 > MyClass 2
MyClass 2 > MyClass 1

If I made a property to retain the value it would automatically mean that I
get a retain cycle.

I guess I should tell you more about the model so you would get the picture.
I am modeling a network of physical processes, look at the representation:

http://i729.photobucket.com/albums/ww297/karolisr/example.png

As you can see each box has one or more little "inputs" and "outputs" in
fact these inputs and outputs are instances of one class (KROMPort). When I
drag a connection from output to an input, I set each "port's" connection
property to point to another "port". So Input points to Output and Output
points to Input. Only one-to-one relationships are allowed (one connection
per input/output). Essentially this is what I have:

KROMPort * input;

KROMPort * output;


output.connection = input;

input.connection = output;


So whenever either an input or output is deleted I have to nil the
connection of the object pointing to the soon to be deallocated object:


self.connection.connection = nil;


SELF here is either an input or an output.


Thanks, Kai, for pointing this out:


The good news is that GC has support for this: weak references. Simply
> declare the connection ivar as weak: __weak MyClass* connection. GC does the
> rest. No dealloc, no finalizer, no dangling pointer. And it’s even thread
> safe.


I never programmed for GC, so I should check then if GC is enabled in my
@interface and create a separate declaration looking like this then?:

"__weak KROMPort * connection"

Thanks all!
___

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: Appropriate dealloc and finalize actions

2009-10-12 Thread Karolis Ramanauskas
Thanks to everyone! Reading all this I realized that there is a little more
to GC than I know... or should I say a lot more. at this point I'm unable to
choose exactly what may be the best solution. I will have to read
documentation and interpret that information through the prism of my
application. Again, thanks for the time you take to consider my problem,
this is a great list. Hope I can reciprocate more than I do.
Karolis
___

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: Appropriate dealloc and finalize actions

2009-10-13 Thread Karolis Ramanauskas
>
> For example, if I were creating an application with documents that
> consisted of connected nodes, I’d have the document own (retain) the nodes
> and have the nodes just reference (assign) each other.


Actually, that's what I do ;)
Thanks
___

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

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

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

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


Re: NSSplitView and NSScrollView

2009-10-15 Thread Karolis Ramanauskas
Good day,
Would you like to share some of your code? It would be a lot easier to see
what may be going on...

Cheers!

On Thu, Oct 15, 2009 at 3:31 AM, Harry Sfougaris  wrote:

> I have placed a NSSplitView inside a NSScrollView in code.
> However, when the user resizes one of the views so part of it outside the
> NSScrollView visible bounds,  the NSScrollView does not display the scroll
> bars.
>
> Is this not possible?
>
>
> Thank you,
> Harry Sfougaris
>
___

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


Malloc leak from ImageIO library

2009-10-15 Thread Karolis Ramanauskas
Good day,

I was running my app with Instruments -> Leaks. This is a
document-based-application. Whenever I save or open a file I get this leak:

Category: Malloc 4.50 KB
Event Type: Malloc
RefCt: 1
Address: 0x103108000
Size: 4608
Responsible Library: ImageIO
Responsible Caller: du_block::set_max_bytes(int, bool)

Is there anything I can do about it? I don't know where to begin... Please
let me know if any other info is necessary, I could attach .trace file from
instruments.

Thanks.

Stack trace:

   0 libSystem.B.dylib malloc
   1 libstdc++.6.dylib operator new(unsigned long)
   2 libstdc++.6.dylib operator new[](unsigned long)
   3 ImageIO kdu_block::set_max_bytes(int, bool)
   4 ImageIO kd_block::retrieve_data(kdu_block*, int)
   5 ImageIO kdu_subband::open_block(kdu_coords, int*, kdu_thread_env*)
   6 ImageIO kd_decoder::do_job(kdu_thread_entity*, int)
   7 ImageIO kd_decoder::pull(kdu_line_buf&, kdu_thread_env*)
   8 ImageIO kd_synthesis::horizontal_synthesis(kd_vlift_line*, int,
kdu_thread_env*)
   9 ImageIO kd_synthesis::pull(kdu_line_buf&, kdu_thread_env*)
  10 ImageIO kd_multi_component::do_job(kdu_thread_entity*, int)
  11 ImageIO kd_multi_synthesis::get_line(kd_multi_line*, int,
kdu_thread_env*)
  12 ImageIO kd_multi_synthesis::get_line(int, kdu_thread_env*)
  13 ImageIO kdu_region_decompressor::process_generic(int, int, kdu_coords,
int, int, int, kdu_dims&, kdu_dims&, int, bool)
  14 ImageIO kdu_region_decompressor::process(int*, kdu_coords, int, int,
int, int, kdu_dims&, kdu_dims&)
  15 ImageIO kdrc_stream::process(int, kdu_dims&, int&)
  16 ImageIO kdu_region_compositor::process(int, kdu_dims&)
  17 ImageIO _cg_JP2DecompressBand
  18 ImageIO getBandProcJP2
  19 ImageIO glueCopyImageBlockSet
  20 ImageIO ImageProviderCopyImageBlockSetCallback
  21 CoreGraphics img_blocks_create
  22 CoreGraphics img_blocks_extent
  23 CoreGraphics img_interpolate_extent
  24 CoreGraphics img_data_lock
  25 CoreGraphics CGSImageDataLock
  26 libRIP.A.dylib ripc_AcquireImage
  27 libRIP.A.dylib ripc_DrawImage
  28 CoreGraphics CGContextDrawImage
  29 AppKit __-[NSImageRep
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]_block_invoke_1
  30 AppKit -[NSImageRep
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]
  31 AppKit __-[NSImage
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]_block_invoke_1
  32 AppKit -[NSImage _usingBestRepresentationForRect:context:hints:body:]
  33 AppKit -[NSImage
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]
  34 AppKit -[NSCompositeImageRep draw]
  35 AppKit -[NSImageRep drawInRect:]
  36 AppKit __-[NSImageRep
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]_block_invoke_2
  37 AppKit __-[NSImageRep
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]_block_invoke_1
  38 AppKit -[NSImageRep
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]
  39 AppKit -[NSImageRep
_createCGImageForProposedRect:context:hints:flipped:]
  40 AppKit -[NSImageRep CGImageForProposedRect:context:hints:]
  41 AppKit -[NSImageRep CGImageForProposedRect:context:hints:flipped:]
  42 AppKit -[NSImage _createSnapshotRepForRep:rect:context:processedHints:]
  43 AppKit -[NSImage _snapshotRepForRep:rect:context:processedHints:]
  44 AppKit __-[NSImage
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]_block_invoke_1
  45 AppKit -[NSImage _usingBestRepresentationForRect:context:hints:body:]
  46 AppKit -[NSImage
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]
  47 AppKit -[NSImage
_drawMappingAlignmentRectToRect:withState:backgroundStyle:operation:fraction:flip:hints:]
  48 AppKit -[NSImageCell drawInteriorWithFrame:inView:]
  49 AppKit -[NSImageCell drawWithFrame:inView:]
  50 AppKit -[NSControl drawRect:]
  51 AppKit -[NSView _drawRect:clip:]
  52 AppKit -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
  53 AppKit -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
  54 AppKit -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
  55 AppKit -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  56 AppKit -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
  57 AppKit -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
  58 AppKit -[NSView displayIfNeeded]
  59 AppKit -[NSWindow
_reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:]
  60 AppKit -[NSApplication _orderFrontModalWindow:relativeToWindow:]
  61 AppKit -[NSApplication
_commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:]
  62 AppKit -[NSAlert
beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:]
  63 AppKit -[NSSavePanel _overwriteExistingFileCheck:]
  64 AppKit -[NSSavePanel _okForSaveMode]
  65 AppKit -[NSSavePanel ok:]
  66 AppKit -[NSApplication sendAction:to:from:]
  67 AppKit -[NSControl sendAction:to:]
  68 AppKit -[NSCell

Re: Malloc leak from ImageIO library

2009-10-15 Thread Karolis Ramanauskas
Thank you

On Thu, Oct 15, 2009 at 3:05 PM, Ken Ferry  wrote:

> Hi Karolis,
> That one's a false positive.  The JPEG2000 library allocates memory at
> pointer p, but holds onto a pointer q and constant k such that q + k is p.
>
> Leaks cannot tell that the app can still get at the pointer, so it thinks
> the memory has been leaked.
>
> Of course, one never wants to see false positives.  Either leaks or the
> library should be modified to make this go away.  There's a bug for it.
>
> -Ken
> Cocoa Frameworks
>
___

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: I don't understand this leak

2009-10-20 Thread Karolis Ramanauskas
This may be a false positive. I recently had a similar leak:

> Category: Malloc 4.50 KB
> Event Type: Malloc
> RefCt: 1
> Address: 0x103108000
> Size: 4608
> Responsible Library: ImageIO
> Responsible Caller: du_block::set_max_bytes(int, bool)
>

Ken Ferry on this list explained it was a false positive. You may want to
show your stack trace, like I did in my recent post, to help people discover
the problem.

On Tue, Oct 20, 2009 at 12:36 PM, Eric E. Dolecki wrote:

> Instruments:
> Malloc 128 Bytes   0x7100780  128 Bytes   CoreGraphics
> open_handle_to_dylib_path
> Malloc 128 Bytes   0x3d0aa50  128 Bytes   CoreGraphics
> open_handle_to_dylib_path
>
> I am not sure what this is... AppDelegate adding subview? Is this a bug in
> Instruments, or something else?
>
___

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


Multithreading NSBezierPath creation and stroking. Measuring performance

2009-10-27 Thread Karolis Ramanauskas
Good day,

For the last few days I've been working on my own "2D Scatter Plot View" all
is going great and it looks nice:

http://i729.photobucket.com/albums/ww297/karolisr/Screenshot2009-10-27at12636AM.png

At this point I started optimizing drawing, so I implemented some cacheing,
etc. and I see significant performance gains. Now my attention is on drawing
multiple series as can be seen in the picture above. I decided that this is
a great place to introduce some multithreading (note that I have never done
any multithreading until two days ago). I've been reading documentation and
this is what I came up with:

   1. For each series create an operation using NSInvocationOperation
   2. The operation consists of:
  - looping through the points in the series and creating an
  NSBezierPath
  - creating NSBitmapImageRep
  - creating NSGraphicsContext with that NSBitmapImageRep
  - stroking the path onto that Bitmap
  - adding Bitmap to an array
   3. In the queue I wait until all the operations are finished and then
   proceed to loop over all Bitmaps and drawing them

I will post detailed code in reply to this post soon (original message was
too big and required approval). My questions are:

   1. Is this a correct approach?
   2. How do I measure (using instruments, I guess) the performance gain, if
   any?

Thanks to everyone,
Karolis
___

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: Multithreading NSBezierPath creation and stroking. Measuring performance

2009-10-27 Thread Karolis Ramanauskas
attached is the .m file with relevant code...


KR2DScatterPlotViewPlot.m
Description: Binary data
___

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: Multithreading NSBezierPath creation and stroking. Measuring performance

2009-10-27 Thread Karolis Ramanauskas
Just noticed I forgot to lock:

[plotBitmaps addObject:bitmap];
___

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


Single Static Library for iPhone and Desktop applications

2009-10-28 Thread Karolis Ramanauskas
Good day,

I'm trying to set up a single static library, I only need it to link against
Foundation, for both iPhone and Desktop applications. I can easily configure
one library for iPhone application only, same with desktop application.
However when I try to make one static library work with both environments I
get into trouble. Is there a way to configure static library for such
situation? Perhaps I just don't know how to do this manually, as Xcode has
templates for the other two variants.

Thanks,
Karolis
___

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: Single Static Library for iPhone and Desktop applications

2009-10-28 Thread Karolis Ramanauskas
...also I wanted to ask, in case this is not possible how do I avoid copying
existing classes I have written for desktop and using them in iPhone? I can
easily create two versions of static library and keep copying/pasting files
between them, but it seems cumbersome.

Thanks again
___

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: Single Static Library for iPhone and Desktop applications

2009-10-28 Thread Karolis Ramanauskas
Thanks to you both, I'll look into my options more deeply. Sorry about the
wrong list...
___

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


Subtle differences in the implementation of the Foundation framework on iPhone and OSX

2009-11-06 Thread Karolis Ramanauskas
Hello there,

Thought I'll share a little observation I just made, and that cost me about
an hour to debug. This is in hope that, using my experience, you may check
for similar bugs.

Look at this piece of code:

///

 NSNumberFormatter * nf = [[[NSNumberFormatter alloc] init] autorelease];

 [nf setNumberStyle:NSNumberFormatterSpellOutStyle];

 NSNumber * result = [nf numberFromString:@" five"];

 NSLog(@"result: %@", result);

 ///

If you were to run it in 10.6, no problem, it will return 5. However on the
iPhone (or, at least, on the simulator) you'll get a beautiful (null). The
problem seems to be the space in the string in front of 'five'. Apparently
OSX implementation of NSNumberFormatter trims the string while iPhone
implementation doesn't. I noticed this because I have a project with two
targets, one for iPhone and one for OSX. My application kept returning
different results while using the same source until I found this tidbit. So
I trimmed whitespace and it's all great.

Also, are there other similar inconsistencies I should be aware of that any
of you know of?

Peace,
Thanks
___

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

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

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

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


Re: Very, Very Simple iPhone SDK Question

2009-11-06 Thread Karolis Ramanauskas
Hi,

You need to use CG structs on iPhone. CGPoint, CGRect... Don't forget
different make function naming conventions either: NSMakeRect -> CGRectMake.

Karolis,
Cheers

On Thu, Nov 5, 2009 at 4:56 AM, Patrick William Walker <
patrick.william.wal...@nb.sympatico.ca> wrote:

> Why do I get an "Expected specified-qualifier-list before NSPoint" when
> trying to port of my model classes from Cocoa to iPhone SDK?  I've been
> reading through the documentation and haven't really found much to explain
> why I'm getting errors when using other things like NSRect and NSBezierPaths
> as well.
>
>
> #import 
>
> @interface Member : NSObject {
>NSPoint a;
> }
>
> @end
>
>
> Thanks for any information.
___

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


Strange NSNumberFormatter behavior

2009-11-10 Thread Karolis Ramanauskas
Good evening,

My question involves the code below:

NSNumberFormatter * nf = [[[NSNumberFormatter alloc] init] autorelease];

[nf setNumberStyle:NSNumberFormatterSpellOutStyle];

 NSLog(@"'%@'", [nf numberFromString:@"one"]); // <- LINE A

NSLog(@"'%@'", [nf numberFromString:@"one two"]); // <- LINE B


On OSX10.6, line A will generate '1', however line B will generate 'nil'.
This is the behavior on which my method relies. However, the same code on
iPhone (or at least iPhone Simulator 3.1) generates '1' in both cases, this
causes my method to behave differently on these platforms. I was trying
different NSNumberFormatter properties to achieve the same behavior with no
avail.

I've also tried getObjectValue:forString:range:error method and it has the
same behavior.

Any help is appreciated.

Thanks
___

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

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

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

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


Re: iPhone CLLocation Accuracy?

2009-11-11 Thread Karolis Ramanauskas
Just a note, kCLLocationAccuracyBest will use the most battery power because
it is actually, most likely, gonna be using GPS radio. If you need just a
general location and not the precise spot, use less precise settings which
will make use of wireless towers and Wi-Fi spots.

On Wed, Nov 11, 2009 at 4:31 PM, Alfonso Urdaneta  wrote:

> Chunk 1978 wrote:
>
>> how accurate is CLLocation's kCLLocationAccuracyBest?  about a meter
>> or more?  or is it hyper accurate as in centimeters?  anyone know?
>>
>
> I'd guess metres at 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Sync my iPhone app with the Desktop version

2009-11-15 Thread Karolis Ramanauskas
Good day,

Does anyone here have pointers on how to implement syncing of my iphone
application with the desktop version. I am interested in the way "Things" on
iPhone does it, for example: http://bit.ly/OrLhi. They use wi-fi. The
biggest problem I have digging up any information is that looking for
"iPhone app sync" and similar queries in Google give me a lot of "junk",
e.g., the results usually have to do with iTunes app sync, etc.

If anyone here have any experience with this, please drop me a bone or
two...

Thanks and Regards,
Karolis
___

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


Synchronization & Core Data

2009-11-15 Thread Karolis Ramanauskas
Good evening to everyone,

I'm in a (extensive) planning stage of a project and an issue of
synchronization is forcing itself on me, I asked a question this morning
about a networking side of things, and I got some info from nice people here
about MYNetwork: http://bitbucket.org/snej/mynetwork/wiki/Home (I want to be
able to sync data between Desktops and iPhones on a local network).

However, now I'm wondering how should I organize / store my data. I want to
use CoreData and I could, easily. I probably won't even have to write a lot
of code as I'm storing numbers, strings, and dates. Most of the behavior I
need is free. But how would I sync core data stores between devices? Only
info I could find was this post:
http://forums.pragprog.com/forums/90/topics/3201. Perhaps someone has some
experience with this? Should I do, as the post says, and create "date
modified" attribute and write my own logic? Or is it possible, after all, to
get some behavior for free from core data framework?

Thanks,
Karolis
___

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: Synchronization & Core Data

2009-11-15 Thread Karolis Ramanauskas
Ha! I just saw that book Amazon a few hours ago, but for some reason didn't
bother looking through the contents. I assumed I need an iPhone book.
Thanks!

On Sun, Nov 15, 2009 at 11:54 PM, Martin Hewitson <
martin.hewit...@aei.mpg.de> wrote:

> Apple's API for Persisting Data on Mac OS X
___

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: Synchronization & Core Data

2009-11-16 Thread Karolis Ramanauskas
Hmm,

So I am reading this ("Core Data: Apple's API for Persisting Data on Mac OS
X") and I see:

1. It covers sync services, which, I understand, I can't use to sync with
iPhone.
2. It covers core-data for iPhone in general, however that doesn't solve my
specific problem.
3. It covers the networking side and using NSManagedObject in a distributed
manner, however it only mentions in the last paragraph of "Distributed Core
Data" that:

"The design that we built here can also be used in a peer environment as
opposed to the client-server design. Multiple peers could use Bonjour to
discover each other and use distributed objects to sync their data stores so
that each device has a complete and up-to-date copy of the data set. In a
situation like that, a user could have our application on each of their
machines, and whenever they are near each other (that is, on the same local
network), they would automatically update each other. Talk about a pleasant
user experience!"

As you can see they do not talk about actually implementing synchronization,
so my original question stands. Any ideas are appreciated.

Thanks

On Sun, Nov 15, 2009 at 8:49 PM, Karolis Ramanauskas wrote:

> Good evening to everyone,
>
> I'm in a (extensive) planning stage of a project and an issue of
> synchronization is forcing itself on me, I asked a question this morning
> about a networking side of things, and I got some info from nice people here
> about MYNetwork: http://bitbucket.org/snej/mynetwork/wiki/Home (I want to
> be able to sync data between Desktops and iPhones on a local network).
>
> However, now I'm wondering how should I organize / store my data. I want to
> use CoreData and I could, easily. I probably won't even have to write a lot
> of code as I'm storing numbers, strings, and dates. Most of the behavior I
> need is free. But how would I sync core data stores between devices? Only
> info I could find was this post:
> http://forums.pragprog.com/forums/90/topics/3201. Perhaps someone has some
> experience with this? Should I do, as the post says, and create "date
> modified" attribute and write my own logic? Or is it possible, after all, to
> get some behavior for free from core data framework?
>
> Thanks,
> Karolis
>
___

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: IBOutlets or property + binding

2009-11-19 Thread Karolis Ramanauskas
>
> Would you create IBOutlets or properties + binding in that case?


You will need to give an example of exactly what you want to accomplish.
What values do you need?, etc. Then, perhaps it will be easier to answer.

Peace
- Hide quoted text -

On Thu, Nov 19, 2009 at 5:48 AM, Christian Ziegler 
 wrote:

> Hi all,
>
> once again I got a rather general question:
>
> Say we got some view-elements which we don't wanna change in any way. We
> only need to read their value to compute something. Would you create
> IBOutlets or properties + binding in that case? Those values are not part of
> my model. They are not being persisted and I only need them temporarily to
> compute stuff.
>
> Thanks in advance,
> Chris
___

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

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

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

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


Re: IBOutlets or property + binding

2009-11-19 Thread Karolis Ramanauskas
Arghh... I was beaten to an answer! :) Slow typing...

Yeah, with bindings you will get a two-way connection. If you change your
property's value programmatically, the stepper will update also.

Instead of target-action you could set up an iboutleted property, connect
stepper to it and observe that property for changes. This may be a more
cumbersome approach in this case though.

Karolis

On Thu, Nov 19, 2009 at 11:45 AM, Keary Suska wrote:

> On Nov 19, 2009, at 10:32 AM, Christian Ziegler wrote:
>
> > For instance I got a NSStepper and I only need the integerValue of that
> stepper. I could either define an IBOutlet and access the integerValue with
>  [stepper integerValue], or I could define a property and bind the steppers
> value to it. As I mentioned I don't have to manipulate that stepper in any
> way, I really only need the value. I just wanna know what's best practice.
>
> Bindings are generally used to synchronize between a model object and view.
> When considering a one-way actions, I generally use IBOutlets to manipulate
> a view, but use target-action for passive activities. So, if it were me, and
> all I cared about was what value an NSStepper was set to, I would just set
> the target/action to my controller object and read the value in the action.
> Although in this case I would set autorepeat to NO so my method is only
> called once.
>
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
>
___

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

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

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

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


Re: IBOutlets or property + binding

2009-11-20 Thread Karolis Ramanauskas
Let me see.

The way I understand what you want to do is this:

You have some controls in your window: c1, c2, c3, c4...

You don't care to be notified when they change. Only thing you care about is
to read their values when you click a button. I thing the best thing to do
here is just create a bunch of IBOutleted ivars:

IBOutlet NS... * c1
IBOutlet NS... * c2
IBOutlet NS... * c3
IBOutlet NS... * c4

Then in you simply have one method that responds to a click:

(IBAction)buttonClicked:(id)sender

{
NSInteger var1 = [c1 intValue];
NSInteger var2 = [c2 ...

do whatever...
}

So in this method you read the values, do something with them and you're
done!

Peace,
Karolis
___

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: How to change UITableView cell style dynamically

2009-11-21 Thread Karolis Ramanauskas
I don't see an example of how you are creating cells in your first post. But
in case you were using the same string for the reuse identifier then when
the cell is loaded the second time it will not switch to a different style.
Because whatever cell was cashed the first time it will be reused. That's
the point. You should create two different reuse identifiers for two
different types of cells. Then in your "if" blocks you should check if the
cell is already cached for that reuse identifier, if it isn't create a new
one. It seems that you were creating a cell outside of the "if" blocks using
one identifier.

Peace,
Karolis

On Sat, Nov 21, 2009 at 3:55 AM, Tharindu Madushanka
wrote:

> Hi
>
> Removing reuse identifier solved the problem so now I am creating a cell
> like below. It worked.
>
> UITableViewCellStyle style;
> if(profile.name.length > 0) {
>style = UITableViewCellStyleSubview;
> } else {
>style = UITableViewCellStyleDefault;
> }
>
> UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:style
> reuseIdentifier:nil]autorelease];
>
> No reuse identifiers or dequeue method in table view is not used while
> creating cells
>
> Since its only once cell, doing this is ok ? is it ?
>
> -Tharindu
> ___
>
> 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/karolisr%40gmail.com
>
> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: mySQL client lib linking problem...

2009-11-22 Thread Karolis Ramanauskas
I think your dylib file has been compiled under debug only. When you compile
your app under release, the compiler complains that dylib is compiled under
debug. Recompile your dylib under release then compile your app under
release. Better yet you should add you dylib project (drag and drop) to your
app project and then in your app's target add dylib as "direct dependence"
this way it will recompile whenever you compile your app.

Karolis

On Sun, Nov 22, 2009 at 11:19 PM, Michael Davey  wrote:

> I am using the mysql c library in my application, and have wrapped the C
> calls in an objective-C class (source available if needed).
>
> I have added the linking references as per instructions I have found on the
> web and when I run my application in debug mode everything works just fine,
> however, when I build it for release, I get a lot of errors that seem to
> stem from the following:
>
> ld: warning: in /usr/local/mysql/lib/libmysqlclient_r.dylib, file is not of
> required architecture
>
>
> What does this mean if my application compiles and runs just fine in debug
> mode? I have checked and the links to the zlib and mysqlclient are present
> for both build configurations, but for whatever reason, it will not build in
> release.
>
> Any help will be gratefully received...
>
> Mikey___
>
> 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/karolisr%40gmail.com
>
> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: mySQL client lib linking problem...

2009-11-22 Thread Karolis Ramanauskas
I made a little mistake. It's not a debug/release issue, although that would
give you similar problems. The dylib you have was compiled under different
configuration! Is your project 64 bit or 32 bit? Try changing that.

On Sun, Nov 22, 2009 at 11:52 PM, Michael Davey  wrote:

> The dylib is the one that comes from the OS X build of mySQL - I did not
> build it myself :o(
>
> On 23 Nov 2009, at 16:50, Karolis Ramanauskas wrote:
>
> I think your dylib file has been compiled under debug only. When you
> compile your app under release, the compiler complains that dylib is
> compiled under debug. Recompile your dylib under release then compile your
> app under release. Better yet you should add you dylib project (drag and
> drop) to your app project and then in your app's target add dylib as "direct
> dependence" this way it will recompile whenever you compile your app.
>
> Karolis
>
> On Sun, Nov 22, 2009 at 11:19 PM, Michael Davey wrote:
>
>> I am using the mysql c library in my application, and have wrapped the C
>> calls in an objective-C class (source available if needed).
>>
>> I have added the linking references as per instructions I have found on
>> the web and when I run my application in debug mode everything works just
>> fine, however, when I build it for release, I get a lot of errors that seem
>> to stem from the following:
>>
>> ld: warning: in /usr/local/mysql/lib/libmysqlclient_r.dylib, file is not
>> of required architecture
>>
>>
>> What does this mean if my application compiles and runs just fine in debug
>> mode? I have checked and the links to the zlib and mysqlclient are present
>> for both build configurations, but for whatever reason, it will not build in
>> release.
>>
>> Any help will be gratefully received...
>>
>> Mikey___
>>
>> 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/karolisr%40gmail.com
>>
>> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: mySQL client lib linking problem...

2009-11-22 Thread Karolis Ramanauskas
I guess you found the answer as I was typing my correction. Do you have the
source to dylib you are using?

On Sun, Nov 22, 2009 at 11:54 PM, Karolis Ramanauskas wrote:

> I made a little mistake. It's not a debug/release issue, although that
> would give you similar problems. The dylib you have was compiled under
> different configuration! Is your project 64 bit or 32 bit? Try changing
> that.
>
>
> On Sun, Nov 22, 2009 at 11:52 PM, Michael Davey wrote:
>
>> The dylib is the one that comes from the OS X build of mySQL - I did not
>> build it myself :o(
>>
>> On 23 Nov 2009, at 16:50, Karolis Ramanauskas wrote:
>>
>> I think your dylib file has been compiled under debug only. When you
>> compile your app under release, the compiler complains that dylib is
>> compiled under debug. Recompile your dylib under release then compile your
>> app under release. Better yet you should add you dylib project (drag and
>> drop) to your app project and then in your app's target add dylib as "direct
>> dependence" this way it will recompile whenever you compile your app.
>>
>> Karolis
>>
>> On Sun, Nov 22, 2009 at 11:19 PM, Michael Davey wrote:
>>
>>> I am using the mysql c library in my application, and have wrapped the C
>>> calls in an objective-C class (source available if needed).
>>>
>>> I have added the linking references as per instructions I have found on
>>> the web and when I run my application in debug mode everything works just
>>> fine, however, when I build it for release, I get a lot of errors that seem
>>> to stem from the following:
>>>
>>> ld: warning: in /usr/local/mysql/lib/libmysqlclient_r.dylib, file is not
>>> of required architecture
>>>
>>>
>>> What does this mean if my application compiles and runs just fine in
>>> debug mode? I have checked and the links to the zlib and mysqlclient are
>>> present for both build configurations, but for whatever reason, it will not
>>> build in release.
>>>
>>> Any help will be gratefully received...
>>>
>>> Mikey___
>>>
>>> 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/karolisr%40gmail.com
>>>
>>> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: mySQL client lib linking problem...

2009-11-23 Thread Karolis Ramanauskas
Glad you found your solution... This is out of my league. Quite interesting
though, so I will creep this exchange.

Peace

On Mon, Nov 23, 2009 at 1:32 AM, Michael Davey  wrote:

> Well, it may not have been the most elegant of solutions, but it works...
>
> Basically I downloaded the binary tarballs for each of the relevant
> architectures from the mySQL download page, and then used lipo to stitch the
> client libraries into the universal binary that I needed.  As an aside I
> have the 64bit PPC version as well - does anyone know if this is needed?
>
> Many thanks to all for your help,
>
> Mikey
>
> On 23 Nov 2009, at 18:10, Andrew Farmer wrote:
>
> > On 22 Nov 2009, at 22:33, Michael Davey wrote:
> >> Yeah, thanks - but given that I cannot even get it to build I will worry
> about that once I get to the point where it is distributable ;o)
> >
> > Fair enough!
> >
> > For what it's worth, you should be able to compile a universal MySQL by
> downloading the source and running:
> >
> > export CFLAGS=-arch ppc -arch i386 -arch x86_64
> > export CXXFLAGS=-arch ppc -arch i386 -arch x86_64
> > export LDFLAGS=-arch ppc -arch i386 -arch x86_64
> > ./configure --enable-static --disable-dependency-tracking
> > make
> > sudo make install
> >
>
> ___
>
> 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/karolisr%40gmail.com
>
> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Build target question

2009-11-23 Thread Karolis Ramanauskas
Perhaps not quite what you need but I am working on code for iPhone and OSX
in parallel and I am using one main.m, one Prefix.pch. I believe you will
need several info.plist files because target specific stuff lives in them,
this is easy though because you point to info.plist from the target info
panel's build tab.

You may need to find a way to separate what part of prefix.pch or main.m is
meant for which target. I am doing this with:

#if TARGET_OS_IPHONE

you may need some other #if statements or may not, since you are not
building for a different platform.

Karolis

On Mon, Nov 23, 2009 at 7:51 PM, Michael Davey  wrote:

> I am about to add a new target to my project as it will be re-using a lot
> of the code generated from my server application and I do not want to start
> creating duplicate copies of classes that I am writing.  So far, so good, I
> am finding my way around making my new target, but have a quick question
> about sharing...
>
> Is it possible for me to use the same main.m Prefix.pch and Info.plist file
> in both of my applications or will that muck things up?
>
> regards,
>
> Mikey___
>
> 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/karolisr%40gmail.com
>
> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Making NSFetchedResultsController register changes to the entity's relationship, not just attributes

2009-12-03 Thread Karolis Ramanauskas
Good day,

I have an NSFetchedResultsController set up with an entity, ENTITY. ENTITY
has a to-one relationship called REL. Now, in my table view, cells display
some data that are the attributes of ENTITY and some data that are the
attributes of REL. When I change the values of the attributes of ENTITY,
everything works great, e.g., the delegate receives a notification and
controller:didChangeObject:...
method fires. However when I change the attributes of ITEM, the change
notification does not fire. I do realize this is not necessarily a bug since
I did not update the ENTITY's attributes, however my table view cells now
appear out of sync. To overcome this problem, I do this whenever I update
REL's attributes:

[self.ENTITY willChangeValueForKey:@"REL"];

[self.ENTITY didChangeValueForKey:@"REL"];

This causes the change notification to fire. I was wondering, if there is a
better way to make NSFetchedResultsController know that it should update in
this case.

Thank you very much,
Karolis R.
___

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


Making NSFetchedResultsController register changes to the entity's relationship, not just attributes

2009-12-03 Thread Karolis Ramanauskas
Good day,

I have an NSFetchedResultsController set up with an entity, ENTITY. ENTITY
has a to-one relationship called REL. Now, in my table view, cells display
some data that are the attributes of ENTITY and some data that are the
attributes of REL. When I change the values of the attributes of ENTITY,
everything works great, e.g., the delegate receives a notification and
controller:didChangeObject:... method fires. However when I change the
attributes of ITEM, the change notification does not fire. I do realize this
is not necessarily a bug since I did not update the ENTITY's attributes,
however my table view cells now appear out of sync. To overcome this
problem, I do this whenever I update REL's attributes:

[self.ENTITY willChangeValueForKey:@"REL"];
[self.ENTITY didChangeValueForKey:@"REL"];

This causes the change notification to fire. I was wondering, if there is a
better way to make NSFetchedResultsController know that it should update in
this case.

Thank you very much,
Karolis R.
___

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: MacResearch Tutorial on beginning a Cocoa/iPhone app.

2009-12-03 Thread Karolis Ramanauskas
Agreed, no network connection no graph! ;) What if I need to update my graph
live?

On Thu, Dec 3, 2009 at 2:48 PM, Philip Vallone
wrote:

> This post is very misleading. The tutorial is called "Using VVI for
> Graphing on iPhone" however there is no graphing. The graph is pulled in
> from the website and viewed through the UIWebView.
>
> Just my thoughts...
>
>
>
>
> On Dec 3, 2009, at 12:09 PM, lbland wrote:
>
> > hi-
> >
> > Occasionally I see a trouble-getting-started post on this list. There is
> a great Cocoa/Xcode/iPhone tutorial on MacResearch:
> >
> > Using VVI for Graphing on iPhone
> > http://www.macresearch.org/using-vvi-graphing-iphone
> >
> > Explaining in precise detail how to make a simple iPhone app. I may be a
> bit partial to the writing style though :-)
> >
> > thanks!-
> >
> > -lance
> >
> >
> > ___
> >
> > 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/philip.vallone%40verizon.net
> >
> > This email sent to philip.vall...@verizon.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/karolisr%40gmail.com
>
> This email sent to karol...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


UITableView / iPhone Calendar List View Question

2009-12-17 Thread Karolis Ramanauskas
Dear developers,

I do not have an iPhone, so I may be wrong since Calendar is not available
on the simulator. UITableView needs to know the number of sections and rows
for each section beforehand. However, Calendar allows repeating events that
do not end, correct? If this is not correct, then my question may be
irrelevant.

If this is correct then how is the list view implemented? If I have, let's
say, an event that repeats every wednesday forever, how do I implement
UITableView? One option is to expand the recurrent dates for a certain date
range and tell the table view the number of events in that date range, but
then when the user scrolls to the end of that range, the user can't scroll
anymore and the table needs to be reloaded. Is there a technique to update
the table seamlessly, so when a user nears to the end of prefetched data,
more can be supplied, so it looks that scrolling just continues without a
glitch?

I may be missing something here, and perhaps there is a simple solution, but
I can't think of anything right now with my limited experience with iPhone
SDK.

Thanks,
Karolis
___

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: UITableView / iPhone Calendar List View Question

2009-12-17 Thread Karolis Ramanauskas
On Thu, Dec 17, 2009 at 9:05 PM, Luke the Hiesterman wrote:

> You can tell the tableView that you have a very large number of rows.
> tableView:cellForRowAtIndexPath: is only called when a cell will actually
> come into view, so even though you claim your table to be very large, not
> all cells are loaded immediately.
>
> Luke
>

I understand that. This approach doesn't seem right though. Let's say I tell
UITableView that I have n number of sections, the user still could, in
principle, get there... Is there such a limit on the list view in Calendar
app?
___

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: UITableView / iPhone Calendar List View Question

2009-12-17 Thread Karolis Ramanauskas
On Thu, Dec 17, 2009 at 9:13 PM, Luke the Hiesterman wrote:

> Yes, eventually the calendar list view will come to an end. I'm able to hit
> that point easily by scrolling fast for several seconds on my phone.
>
> Luke
>

Ah, I see! So it's all an illusion! ;) Thanks. Just to confirm, you have
repeating events that do not end, but the list view ends at some remote
future date? How much in the future, if it's not too much of a trouble ;)

Thanks
___

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

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

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

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


Re: UITableView / iPhone Calendar List View Question

2009-12-17 Thread Karolis Ramanauskas
Thank You. Good to know there is no "magic" there.

On Thu, Dec 17, 2009 at 9:18 PM, Luke the Hiesterman wrote:

> I don't know at what point the calendar is setup to end, but the principle
> is there. Calendar doesn't even go all that far with it. You could easily
> declare 30k rows and there's no reason a user should ever get through that
> many rows.
>
> Luke
>
> On Dec 17, 2009, at 7:15 PM, Karolis Ramanauskas wrote:
>
> On Thu, Dec 17, 2009 at 9:13 PM, Luke the Hiesterman 
> wrote:
>
>> Yes, eventually the calendar list view will come to an end. I'm able to
>> hit that point easily by scrolling fast for several seconds on my phone.
>>
>> Luke
>>
>
> Ah, I see! So it's all an illusion! ;) Thanks. Just to confirm, you have
> repeating events that do not end, but the list view ends at some remote
> future date? How much in the future, if it's not too much of a trouble ;)
>
> Thanks
>
>
>
___

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

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

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

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


Re: UITableView / iPhone Calendar List View Question

2009-12-17 Thread Karolis Ramanauskas
Luke helped me with this a little bit, but, after experimenting, it seams
there is more to it.

I guess there is still something I do not understand about this. Yes, I can
set a huge number of rows. But I want them to be grouped into sections.
However, UITableView wants to know exactly how many rows are in each section
on load time, even for invisible sections. So, if I have a rule that
describes recurring events in my model, that means I would have to expand
these and calculate, number of rows per section on load. If I have, let's
say, 10,000 sections (to imitate the never-ending list) this may be a costly
calculation. I assume there is no way around this, but limiting the number
of sections to a lot lower numbers...

Peace.
___

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: UITableView / iPhone Calendar List View Question

2009-12-17 Thread Karolis Ramanauskas
Well, I'm in early stages of design. Just playing around, no specification
yet, so I'm not too worried. I'm throwing ideas around.

Well I'm trying to do the same thing here. I store the rule for expansion of
dates, let's say:

repeats weekly, tuesdays and thursdays, starts on date x, ends never, etc...

Since I'm not storing every instance, it's impossible and impractical, there
is an infinity, I need to "expand" these dates to show as table cells when
needed...

Anyway, I thought it through again and it really isn't that impractical,
because, let's say I have twenty different repeating events that never end.
There will be periodicity when they occur and I won't need to recalculate
the number of rows for each section.

Sorry.

On Thu, Dec 17, 2009 at 10:47 PM, Luke Hiesterman wrote:

> It sounds like you have a design problem if you want potentially large
> numbers of sections but it isn't easy to calculate the size of said
> sections. What are you really trying to do?
>
> Luke
>
> Sent from my iPhone.
>
>
> On Dec 17, 2009, at 8:01 PM, Karolis Ramanauskas 
> wrote:
>
>  Luke helped me with this a little bit, but, after experimenting, it seams
>> there is more to it.
>>
>> I guess there is still something I do not understand about this. Yes, I
>> can
>> set a huge number of rows. But I want them to be grouped into sections.
>> However, UITableView wants to know exactly how many rows are in each
>> section
>> on load time, even for invisible sections. So, if I have a rule that
>> describes recurring events in my model, that means I would have to expand
>> these and calculate, number of rows per section on load. If I have, let's
>> say, 10,000 sections (to imitate the never-ending list) this may be a
>> costly
>> calculation. I assume there is no way around this, but limiting the number
>> of sections to a lot lower numbers...
>>
>> Peace.
>> ___
>>
>> 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/luketheh%40apple.com
>>
>> This email sent to luket...@apple.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: NSDate without time portion

2010-01-05 Thread Karolis Ramanauskas
>
> By formatting the dates as MMDD and keeping them in strings you can use
> simple string comparison to sort, compare and filter. They are also very
> easy to format for display purposes. If you want to go standard then use the
> ISO 8601 date format. It's -MM-DD. See
> http://www.iso.org/iso/date_and_time_format
>

Great, but do not forget, in this case, to store time zone information too,
perhaps in a separate string. Time offset won't do because it may change for
the same time zone depending on daylight savings time. If I store date as a
string, I also store the associated time zone's "name" property. NSDate is
more than a plain date. It has time zone info embedded. Just try printing
the same date object on daylight savings time date and not, and you will see
the date object automatically adjusts the time. So, hypothetically if you
stored 2009-12-31 as a string. Then created NSDate object from that string.
It may later be interpreted as 2009-12-31 00:00:00 or, let's say 2009-12-30
23:00:00 or 2009-12-31 05:00:00, if the time zone of your user computer
changes. Think, what if you user saves an appointment at 12:00:00 in New
York and you store it as a string with no time zone info? In Chicago, that
appointment will appear at 12:00:00 also even though it is really happening
at 11:00:00.

Peace.
___

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: NSDate without time portion

2010-01-05 Thread Karolis Ramanauskas
>
> NSDate conceptually store time relative to Jan 1, 2001, GMT.
>
> When it is formatted for display, it uses the current time zone (or more
> correctly, the NSDateFormatter uses whatever time zone has been specified,
> or the current system time zone).  If your time zone changes (such as by
> daylight savings time, or changing the location), the resulting date will
> print differently, but timeIntervalSinceReferenceDate will be unchanged.  It
> is ultimately the date formatter that handles time zones, daylight savings
> time, etc...


HA!, Thanks, I see...

Either way though, If I choose to store the date as a string somewhere, I
would need to store time zone, as this is a lossy way of storing a date. Of
course it may be good to store the date as time relative to Jan 1, 2001,
GMT.
___

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


Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-24 Thread Karolis Ramanauskas
Good day, everyone,

I have a core data document based app. There are two windows for each
document. One is the "Inspector" window with mostly NSTableViews
representing objects and their relationships. Another window consists of a
custom view which draws graphical representation of the objects. In my
custom view I use NSManagedObjectContextObjectsDidChangeNotification
observer to refresh the view whenever there are any changes in the
NSManagedObjectContext.

Weird behavior: After adding a few objects whenever I move a mouse over the
NSTableViews (or more accurately NSScrollViews enclosing them), the
NSManagedObjectContextObjectsDidChangeNotification is triggered! Actually it
gets triggered by more than that, but I'm not doing anything to change
NSManagedObjectContext. Why would simply moving a mouse over certain areas
of the before mentioned views trigger that event to fire? It cause
completely unnecessary refreshes and makes the view flicker more than it
should...

Any help is greatly appreciated!

Thanks,
Karolis
___

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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-24 Thread Karolis Ramanauskas
OK, I managed to replicate my problem in this example project:
http://strangeinversion.com/weird.zip

If you are interested download it, only 44KB. It contains two core data
entities: BigBagOfFruit and Fruit.

1. Run the program
2. Add a bag
3. Now add some fruit in it ;)
4. Move your mouse around the window and look at your console:
NSManagedObjectContextObjectsDidChangeNotification get called all the
time...
5. Go to fruit class, comment out: [self setName:@"Banana"];
6. Repeat 1 through 4, problem is gone.

That's what I noticed in my program, whenever there is ANY SETTER within the
draw method that is called from MyView's drawRect, I get this behavior.

Any thoughts?
Thanks a lot.
___

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: plug-in

2009-02-24 Thread Karolis Ramanauskas
if this is the file you are talking about, I had no problem downloading it.
Here I uploaded it to my site:

http://strangeinversion.com/Paper2002.dmg.sit

If it's something else, let me know...
___

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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-25 Thread Karolis Ramanauskas
>Lesson: Don't change model data in a -draw method.  I really can't think of 
>any reason why you'd want to do this.   -draw is for drawing.

Yes, perhaps, but I have to change it, perhaps not in a draw method
itself, but in another method that get's called before it. In my real
program I have one, let's call it, MAIN object that has a draw method
and within it, it calls to draw methods of all its input objects:

NSSet * myInputs = [self inputs];

int inputCount = [myInputs count];

if (inputCount != 0) {

int n = 0;

for (KRSimInput * input in myInputs) {

[input setLocationX: ([self locationX] + ([self width] /
inputCount) * n++ + ([self width] / 2) / inputCount) - ([input width]
/ 2)];
[input setLocationY: ([self locationY] - [input height] -
[input strokeWidth])];

[input draw];

}
}

As you can see, before I can -draw an input I have to position it
right above the MAIN object. This position, as you can see from the
code, depends on inputCount and n, the current index. So I can't avoid
setters in -draw. Any suggestions?
___

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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-25 Thread Karolis Ramanauskas
> Is locationY the model attribute which you "have to" change?  If so, I
> suggest that this is not rightfully a model or managed object attribute.
>  Obviously, it's more of a 'view' thing than a 'model' thing.  Remove it
> from your data model.  Make it a regular instance variable instead or,
> better yet, remove it entirely from your model class and calculate it in
> your view class when you need to draw.  Thousands of apps do it that way --
> it will work for your app too!

All this time thinking, concocting amazingly elaborate schemes how I
will make this work using several notifications, etc... This never
occurred to me! Thanks! It's true, I always dynamically calculate
this... Thanks again.
___

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


Q: Creating bindable properties editors for Core Data entities

2009-02-26 Thread Karolis Ramanauskas
Good day,

First of all I would like to thank to everyone who helped me with my
previous question, I'm passed
NSManagedObjectContextObjectsDidChangeNotification ;)

Here is the scenario, I've looked at the archives, but I am still confused
of the correct plan of action:

I have a custom view that shows representations (draws rectangles) of
instances of core data entities. I set it up so when I double-click on any
of those rectangles I call a method in the controller and pass the required
object instance reference to it:

[[self delegate] showPropertiesWindowFor:currentFlowElement];

Now the controller does this:

- (void)showPropertiesWindowFor:(KRSimFlowElement *)flowElement {

if ([flowElement isKindOfClass:[KRSimAssimilator class]]) {

// SHOW PROPERTIES

}

}

Now, as the method name indicates I would like to create a properties window
for that object instance and show it.

My abstract plan of action:

1. Create a template window in IB;
2. Create several template views in IB containing specific properties for
each entity.

Now I'm lost:

1. How should I proceed? Create separate NIB for this window and views?
2. How do I pass a reference of the selected object to a specific window
from showPropertiesWindowFor:?
3. How do I make the properties bind to that object I just passed?
4. I want to be able to open as many properties windows as I want for each
instance of an object, but if I double click on the object that has a window
already open it should only come into focus...

If anyone has some suggestions, if only to one part of this question, I'd
greatly appreciate that. I'm eager to learn and I'm not looking for complete
solution, but I'd like a roadmap from experienced people.

Thanks again,
Karolis
___

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: Creating bindable properties editors for Core Data entities

2009-02-26 Thread Karolis Ramanauskas
Hello, thnaks for your help, Jon,

So I have a lot of this working now, but I have a problem!

I created a XIB with one window, several views. When a user clicks on the
object in the main view this happens:

- (void)showPropertiesWindowFor:(KRSimFlowElement *)flowElement {

FlowElementsPropertiesWindowController * propertiesController =
[[FlowElementsPropertiesWindowController alloc]
initWithWindowNibName:@"FlowElementsPropertiesWindows"
owner:flowElement];

[propertiesController showWindow:flowElement];

}

(I know the memory management here is a bit iffy ;))

then the controller does this:

- (void)awakeFromNib {


if ([[[self window] delegate] isMemberOfClass:[KRSimAssimilator class]])
{

[[self window] setContentView:assimilatorPropertiesView];

}

if ([[[self window] delegate] isMemberOfClass:[KRSimReserve class]]) {

[[self window] setContentView:reservePropertiesView];

}


}

The problem is that these properties are for core data entities. I set up
bindings for each view separately, but each entity has different attributes.
When I try to load properties for one entity other views complain that that
entity is not key value coding-complient:

[ valueForUndefinedKey:]: the entity KRSimReserve is
not key value coding-compliant for the key areaSpecificIngestionRate.

Is there a way to salvage my structure or will I have to separate each
property view to it's own XIB?

Thanks a lot,
Karolis

On Thu, Feb 26, 2009 at 8:09 AM, Jon C. Munson II  wrote:

> Namaste!
>
> This reply is off-list.
>
> Here is my input, for what it's worth:
>
> >
> > 1. Create a template window in IB;
> > 2. Create several template views in IB containing specific properties for
> > each entity.
> >
> > Now I'm lost:
> >
> > 1. How should I proceed? Create separate NIB for this window and views?
> [Jon C. Munson II] You could without issue.  It may be easier to manage
> your project and create re-usability
>
> > 2. How do I pass a reference of the selected object to a specific window
> > from showPropertiesWindowFor:?
> [Jon C. Munson II] Create an ivar that you would set once you create an
> instance of your window/nib from step 1.
>
> > 3. How do I make the properties bind to that object I just passed?
> [Jon C. Munson II] By passing a reference to the current object, and if
> your object is a Core Data entity (from your title I assume it it), you can
> set the array controller for that object.  From there you can bind your
> properties to the that of the array controller.  Alternatively, you could
> simply bind to your object's properties.  The idea is the same, only the key
> path changes.
>
> > 4. I want to be able to open as many properties windows as I want for
> each
> > instance of an object, but if I double click on the object that has a
> > window
> > already open it should only come into focus...
> [Jon C. Munson II] see -makeKeyAndOrderFront.  Use that after you've
> checked for an instance of that window which you may want to also tie to the
> respective object.
>
___

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

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

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

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


Re: Cocoa Document-based Application Template

2009-02-26 Thread Karolis Ramanauskas
You have to set up how you will save your files first, this is not core
data.

You will have to, for example, create an array that will hold the objects
that you will be archiving and unarchiving to. Then you will have to modify
the dataOfType and readFromData methods:

- (id)init {

self = [super init];
if (self) {

objectsToArchive = [[NSMutableArray alloc] init];
selection = [[NSMutableArray alloc] init];

}

return self;

}

- (void)dealloc {

[objectsToArchive release];
[selection release];

[super dealloc];

}

- (void)addObject : (id)object {

if(![objectsToArchive containsObject:object]) {

[objectsToArchive addObject:object];

}

}

- (void)removeObject : (id)object {

[objectsToArchive removeObject:object];

}

- (void)setObjects : (NSMutableArray*)objects {

[objects retain];
[objectsToArchive release];
objectsToArchive = objects;

}

- (NSArray*)objects {

return objectsToArchive;

}

- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError {

if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:
unimpErr userInfo:NULL];
}

return [NSKeyedArchiver archivedDataWithRootObject:[self objects]];

}

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName
error:(NSError **)outError {

if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:
unimpErr userInfo:NULL];
}

NSArray * arrayWithDataFromFile = [NSKeyedUnarchiver
unarchiveObjectWithData:data];
NSMutableArray * mutableArrayWithDataFromFile = [arrayWithDataFromFile
mutableCopy];

[self setObjects: mutableArrayWithDataFromFile];

[mutableArrayWithDataFromFile release];

return YES;

}

On Thu, Feb 26, 2009 at 11:05 PM, Richard Somers  wrote:

> An application built using the standard unmodified "Cocoa Document-based
> Application" template produces an error when saving. The error message is
> "The document "Untitled" could not be saved as "newname.".
>
> This happens on my PPC and Intel machines.
>
> Does anyone else have this problem?
>
> Mac OS X 10.5.5
> Xcode 3.1.1
>
> Richard
___

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


MVC, storing VIEW-specific information and core data

2009-03-09 Thread Karolis Ramanauskas
Good Day,

I'm in a MVC-induced contradiction here. I've read the archives and found
good answers to many of my questions, however it seems one thing kind of
escaped from being answered. I have Core Data Document Based app. Core Data
model contains entities that describe graph objects (nodes). Of course each
node knows any number of nodes that it has connections to. That's all well
and dandy. I save the model, I open the model, beautiful. Now I want to
write a View that would draw these objects. Of course I should be able to
drag them around the screen all that stuff. But this is purely user
interface stuff I don't want the model to change because I drag stuff
around. What is the best way to store the coordinates, colors, all that UI
stuff using core data? I really don't want to put extra entities within my
.xcdatamodel file that deal purely with UI stuff. While I do realize that I
will have to get this data into the Managed Context somehow in order for it
to be stored automatically with the document, I want to be able to make my
model completely and utterly UI independent.

Any advice is greatly appreciated,
Thanks
___

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

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

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

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


Re: MVC, storing VIEW-specific information and core data

2009-03-09 Thread Karolis Ramanauskas
Thanks Sean, Benjamin and I. Savant for your responses so far,

>You could use the various setMetadata: methods of NSPersistentStore
and NSPersistentStoreCoordinator.
I thought metadata was meant to make stores searchable with spotlight? Is
this the correct usage? I claim ignorance here :)

>You could have a NodeViewState, joined to the Node by a relationship, for
each node to store the view-only parameters.

This is true, but then I have to include extra entities within the data
model that have nothing to do with the graph itself but only with the View.

>IF PERSISTED

Yes, I'd like to save this document with a specific layout and open it.

>What's your aversion to storing this within the nodes themselves? If
>they're meant to be persisted at all, and these properties belong to
>your Node instances, then there's no obvious reason (from your
>description) to create a separate entity to store them. What's the
>problem? Be specific.
Well, perhaps I didn't explain it well enough. Let's say, in the future I
want to have a different View. In that case specific location X and Y for
this view will mean different things or may not be required at all. Perhaps
other View will not need background color or border info, etc. Within my
model objects I just want to store model related information, nothing that
pertains to a particular view. Nevertheless I would like to store whatever
view information I have with the document so when I open it that view is
back to the state user left it at.
___

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: MVC, storing VIEW-specific information and core data

2009-03-09 Thread Karolis Ramanauskas
>
> STOP IT.
>
>  That's right. Stop it.
>
>  No no, just  just stop it.*


I needed that, ;) I can't come up with a better way either, I've been
sitting and reading all this morning, my platonic MVC ideal a little
diminished... Perhaps this could be one-to-many relationship so I could
associate several view settings (for different views, if needed, more than
one view per app) with one object! Ha, really this would only mean adding
one property to my model and it will not even be reflected in code since
Core Data defaults will probably suffice.

Thanks
___

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

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

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

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


Re: MVC, storing VIEW-specific information and core data

2009-03-09 Thread Karolis Ramanauskas
>
> Most of my Core Data entities have a Data blob attribute which is actually
> and archived dictionary of "extra data."  Each user's per-document view
> configuration is stored under keys within each blob.  The Data blobs start
> out nil which just defaults to something reasonable in each view.


 This is what I will probably do. Reasons:

1. No need to create extra entities, objects.
2. Controller may be application specific and take care of deciding what
goes in the "Blob".
3. Only need to fetch this info once at the start, then save it before
closing.


Thanks
___

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

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

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

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


Re: How to use MySql, which api is for that

2009-03-14 Thread Karolis Ramanauskas
I happily used ActiveRecord
http://github.com/aptiva/activerecord/tree/master
Look how nice it is to connect:

NSDictionary * databaseConnectionInfo = [NSDictionary
dictionaryWithObjectsAndKeys:

@"127.0.0.1", @"host",

@"obama", @"user",

@"supersecretpassword", @"password",

@"databasename", @"database",

[NSNumber numberWithInt:3306], @"port", nil];

mySQLConnection = [[ARMySQLConnection alloc] init];

NSError * databaseError = nil;

[mySQLConnection initWithConnectionInfo:databaseConnectionInfo error
:&databaseError];

[mySQLConnection executeSQL:@"TRUNCATE TABLE trial" substitutions:nil];
___

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