nil

What are all these null collection entries in my DataContract XML?

Does anybody know why the NetDataContractSerializer might add "nil" entries in a serialized collection? For example, <Jobs z:Id="17"> <_items z:Id="18" z:Size="4"> <JobRecord z:Id="19"> <Name z:Id="20">Job1</Name> </JobRecord> <JobRecord i:nil="true" /> <JobRecord i:nil="true" /> <JobRecord ...

Memory management, and async operations: when does an object become nil?

I have a view that will be displaying downloaded images and text. I'd like to handle all the downloading asynchronously using ASIHTTPRequest, but I'm not sure how to go about notifying the view when downloads are finished... If I pass my view controller as the delegate of the ASIHTTPRequest, and then my view is destroyed (user navigates...

Sorting by dates (including nil) with NSFetchedResultsController

In my NSFetchedResultsController, I set a sortDescriptor that sorts based on the date property of my managed objects. The problem that I have encountered (along with several others according to Google) is that nil values are sorted at the earliest end rather than the latest end of the date spectrum. I want my list to be sorted earliest...

Assign to an array and replace emerged nil values

Greetings! When assigning a value to an array as in the following, how could I replace the nils by 0? array = [1,2,3] array[10] = 2 array # => [1, 2, 3, nil, nil, nil, nil, nil, nil, nil, 2] If not possible when assigning, how would I do it the best way afterwards? I thought of array.map { |e| e.nil? ? 0 : e }, but well… Thanks! ...

[].include?(:test) return nil [RoR]

Having the strange problem that [].include?(:test) returns nil instead of expected false. The whole thing only happens when running the app (i see it in rubymine debug mode), not in irb or rails console. I tested following [].include?(:test) # nil [].include?(:test).nil? # nil [].class # Array Seems as if include? is overwritten so...

NSInvalidArgumentException: *** -[NSPlaceholderString initWithFormat:locale:arguments:]: nil argument

Found the answer. It was a silly mistake from my part. I did not convert NSNumber to int like how I was supposed to. Thanks for reading ...

Delphi Exception handling problem with multiple Exception handling blocks

I'm using Delphi Pro 6 on Windows XP with FastMM 4.92 and the JEDI JVCL 3.0. Given the code below, I'm having the following problem: only the first exception handling block gets a valid instance of E. The other blocks match properly with the class of the Exception being raised, but E is unassigned (nil). For example, given the curre...

Inserting nil Values into Sqlite Database?

I am working on an iPhone App where I am pulling data from an XML file and inserting it into a sqlite database located in the App. I am able to successfully do this process, but it appears that if I try to sqlite3_bind_text with a NSString that has a value of "nil", the App quickly dies. This is an example of code that fails: (modified...

-sizeWithFont Functions Differently on Device

So I am seemingly encountering some strange behavior when using NSString's -sizeWithFont family of method calls depending on whether or not I'm invoking it on the iPhone Simulator or an actual device. Simply enough, when the receiver of the -sizeWithFont:constrainedToSize:lineBreakMode: method call is nil, the resulting CGSize passed ba...

ActionMailer sent with body unavailable in view

So ive got a ActionMailer mailer class ReportMailer < ActionMailer::Base def notify_doctor_of_updated_document(document) recipients document.user.email_id from "(removed for privacy)" subject "Document #{document.document_number} has been updated and saved as #{document.status}" sent_on Time.now bod...

How do I check if an instance has an object to skip displaying the values?

I have created a polymorphic association around a model called status. Some contacts will have a status associated with it. Many won't. If I try to call a status when one is not there, I get an error. Right now, even if I haven't created a status for the model, it still runs whatever is in the if-end block. Here's what I am trying, ...

Change nil's to zeroes in elisp

Hi all I'd like to ask - what is the function doing nil conversion from nil's to zeroes in elisp? I'm a newbie and I think I am inventing the wheel with my code: (defun chgnull (x) (if (null x) 0 1)) (mapcar 'chgnull '(1 2 nil)) Search through Emacs sources by keyword "to zero" and such haven't shown anything relevant. ...

Strange XCode debugger behavior with UITableView datasource

Hey guys. I've got a perplexing issue. In my subclassed UITableViewController my datasource methods lose their tableview reference depending on lines of code I put inside the method. For example, in this code block: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 3; } ...

Obtaining ActiveRecords if NOT nil

I would like to be able to gather all records in a table where the user_id is not null. This is what I have but it doesn't seem to be working (even though I've had it working in a seperate project): named_scope :all_registered, :conditions => ["user_id != ?", nil] ...

Would a pointer to a pointer to nil match against NULL?

Example: A validation method contains this check to see if an NSError object shall be created or not: - (BOOL)validateCompanyName:(NSString *)newName error:(NSError **)outError { if (outError != NULL) { // do it... Now I pass an NSError object, like this: NSError *error = nil; BOOL ok = [self validateCompanyName:@"Apple"...

Difference between an variable set to nil and 0

if (myFloat == nil){ \\Do Method } In the above situation, the method will run only if myFloat is nil. Will it also run if myFloat was set to 0? ...

Cocoa memory management

At various points during my application's workflow, I need so show a view. That view is quite memory intensive, so I want it to be deallocated when it gets discarded by the user. So, I wrote the following code: - (MyView *)myView { if (myView != nil) return myView; myView = [[UIView alloc] initWithFrame:CGRectZero]; // ...

iPhone SDK: Please explain why "nil ==" is different than "== nil"

I have been programming iPhone SDK for around 6 months but am a bit confused about a couple of things...one of which I am asking here: Why are the following considered different? if (varOrObject == nil) { } vs if (nil == varOrObject) { } Coming from a perl background this is confusing to me... Can someone please explain why on...

Ruby on Rails: Is there a way to make blank form inputs submit nil?

Is there a way to make blank form inputs submit nil? Right now, I'm going through and in a before_save manually converting all "" into nil. This really doesn't seem very DRY, and I feel like I must be missing something. ...

Dealing with nil in views (ie nil author in @post.author.name)

I want to show a post author's name; <% @post.author.name %> works unless author is nil. So I either use unless @post.author.nil? or add a author_name method that checks for nil as in <% @post.author_name %>. The latter I try to avoid. The problem is that I may need to add/remove words depending on whether there is a value or not. For i...