Menu
  • HOME
  • TAGS

UILabel returns “nil”?

swift,uibutton,uilabel,nil,ibaction

It would help if you clarified how you want it to behave. If you're wondering why it's an optional and why it's returning nil then you can fix this as follows. In your checkButton() function you have this line at the end: currentCountLabel.text = "\(currentCount)" Unwrap the currentCount variable to...

checking for nil before sending message

ios,objective-c,xcode6,nil

OK. I am able to fix the issue. It is because inside this User object which is [DataManager sharedInstance].currentUser, userId is declared as both instance variable and property. @interface User : NSObject <NSCopying>{ NSString *userId; // instance variable } @property (nonatomic, retain) NSString * userId; So, by removing the instance...

Swift: label text --> “fatal error: unexpectedly found nil while unwrapping an Optional value”

swift,label,nil

I have tried this code and it working fine for me: class ViewController: UIViewController { var player : Int = Int() //Declare this globally @IBOutlet weak var readyLabel: UILabel! @IBAction func noButton(sender: AnyObject) { exit(0) } // --------------------------------------------------------- @IBOutlet var computerChoice: UILabel! @IBOutlet var playerChoice: UILabel! @IBOutlet var score: UILabel!...

Replace Empty Cells in Array With Nil in Ruby?

ruby,arrays,nil,empty-string

[['cat','','dog',''],['','','fish','','horse']].map do |arr| arr.map { |s| s unless s.empty? } end # => [["cat", nil, "dog", nil], [nil, nil, "fish", nil, "horse"]] ...

NSMutableArray addObject is nil?

ios,objective-c,nsmutablearray,nil

The following line should be using the property and not the instance variable. i.e. you're not actually calling the getter that allocates the array. Change this line: [_numberArrayWaitingForCalculate addObject:[NSNumber numberWithInt:[_valueString intValue]]]; to: [self.numberArrayWaitingForCalculate addObject:[NSNumber numberWithInt:[_valueString intValue]]]; ...

Objective-C Property Getter/Setter crash EXC_BAD_ACCESS

objective-c,cocoa,properties,crash,nil

Your problem is recursion. In the setter, you are calling the setter method again, and again and again. When you declare self.firstName = first name__; is basically the equivalent of [self setFirstName:first name__]; So the method is calling itself which doesn't make much sense to do. You first need to...

IBOutlet of another view controller is nil

swift,nil,iboutlet

IBOutlets are initialized during view loading process and they are not accessible at the point you are trying to reach them. Instead you must declare a string variable to your viewcontroller and set text to label on its viewDidLoad method (after the loading process has finished) class StoryViewController: UIViewController {...

Rails can't select where foreign key is nil

ruby-on-rails,activerecord,nil

The NULL value can be surprising until you get used to it. Conceptually, NULL means “a missing unknown value” and it is treated somewhat differently from other values. You cannot compare null using equal to for this you must use IS NULL. So update your queries to Customer.includes(:orders, :shipping_address).where('customers.shipping_address_id IS...

Table printing nil on Lua

lua,nil,lua-table

Iterating over t doesn't change t. You need to specify where to put the values you are iterating over, and use those variables. local t = { {name="John",sex="M",age=19}, {name="Susan",sex="F",age=20} } for index, value in ipairs(t) do print("NAME: " .. value.name) print("SEX: " .. value.sex) print("AGE: " .. value.age) print("\n") end...

accessing lua self member got nil

lua,member,nil,self,lua-table

When you define a function using the :, the implicit parameter is created on its own. When you are defining the function coreLogic, you'd need to pass it as the first argument: self.coreLogic = function( self, dt ) and that would be the same as: function self:coreLogic(dt) self in itself...

Swift Optionals(?). What's the difference between two?

swift,syntax,nil,optional-parameters,optional

There is no difference between those two lines: var beaconGroup:GroupData = filteredArray.firstObject? as GroupData var beaconGroup:GroupData = filteredArray.firstObject as GroupData In the first, the ? is unnecessary — firstObject already returns an Optional. Using the optional chaining operator without actually chaining a further member lookup or access expression has no...

Clojure deep-merge to ignore nil values

clojure,merge,nil

I found this at: https://github.com/circleci/frontend/blob/04701bd314731b6e2a75c40085d13471b696c939/src-cljs/frontend/utils.cljs. It does exactly what it should. (defn deep-merge* [& maps] (let [f (fn [old new] (if (and (map? old) (map? new)) (merge-with deep-merge* old new) new))] (if (every? map? maps) (apply merge-with f maps) (last maps)))) (defn deep-merge [& maps] (let [maps (filter identity maps)]...

Problems with nil output from NSXMLParser

ios,objective-c,xml,nsxmlparser,nil

In the code that you presented you're missing two things: Ending part of your xml (</content:encoded></item>) Initialization of array variables: datearray, descarray If you don't initialise the arrays in your actual code too, then all you tried to put in them, is lost, and you'll get nil in objectAtIndex. You...

Object is set to nil automatically

ios,objective-c,variables,nil

I usually make headers like this: #import <UIKit/UIKit.h> @interface SettingsViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate> @property (nonatomic, weak) IBOutlet UITextField *userTextField; @property (nonatomic, weak) IBOutlet UITextField *passwordTextField; @property (nonatomic, strong) IBOutlet UIPickerView *elementPicker; // I would suggest to use sttong for outlets if you are planning to move them out of...

Exception isn't thrown when nil inserted in NSDictionary

ios,objective-c,facebook,nsdictionary,nil

You wrote: // Here an exception should be thrown but for some reason // we just quit out of the method. Result would be the same if we put empty "return;" statement. Most likely the exception is caught somewhere. Try putting a breakpoint on Objective-C exception throws (In Xcode, go...

Optional (numeric) attributes without default value in Core Data - why are they discouraged?

objective-c,cocoa,core-data,nil

Say you have a numeric (int for example) optional column in your DB. If you leave it blank, there will be a NULL in the DB. Now say you subclass NSManagedObject and use primitive types in your object. That column will be mapped to an int property. When the object...

swift: delegate is nil after segue

delegates,protocols,segue,nil

First way is to use prepareForSegue and declare in it all your delegate methods. Second way is to use NSNotificationCenter and with this transfer your delegate so this works with pushToViewController...

Kth from the last element in a list using golang

list,recursion,go,nil

You need to pass a pointer to WrapObj to the findKFromLastRecr() function. Similar to the languages in the C family, everything in Go is passed by value. That is, a function always gets a copy of the thing being passed, as if there were an assignment statement assigning the value...

rails if statement in controller - checking nil

ruby-on-rails,ruby,nil

Your code seems fine, I'm betting it's your data that's the problem instead. Mostly likely, assuming this an active record instance, the attribute is id which will be nil until the new record gets saved. What do you get in the terminal when you add this line right before your...

read excel file, work around or with nil? values, edit/format individual column

ruby,format,spreadsheet,nil

designated_rows is holding the entire spreadsheet in memory, now that you have that variable you need to save it down as a new spreadsheet file, or you can do this after you've modified everything: raw_data = Spreadsheet.open '../October 2014.xls' raw_data_sheet = raw_data.worksheet 0 keys = ["N/A", "N/A", 0.0, 0.0, 0.0,...

When should I use nil in objective-c?

objective-c,null,nil

The code samples you cited use it correctly. NSMutableArray * is an Objective-C object pointer type. So we use nil. On the other hand, the second parameter to copyItemAtPath:toPath:error: has type NSError **, which is not an Objective-C object pointer type. It is a regular C pointer to the pointer...

Return object not null but empty

ios,objective-c,core-data,restkit,nil

Oh, I see. You're creating a MOC just for this method and never merging it with the context you're using outside the scope of the method, so your changes after insertion go unsaved. I bet a number of people just skimmed right passed that because the whole MOC entityname/insert junk...

scala Nil type matchs against arraybuffer

scala,pattern-matching,nil,arraybuffer,unapply

With objects, unapply is not involved (that would be the case if you had used the hypothetical case Nil() => ...). Instead, the equality is checked using the equals method. Equality for collections is defined in terms of their elements. E.g. List(1,2,3) == Vector(1,2,3) // true! The same happens with...

Nil Swift Dictionary

ios,swift,dictionary,nil

It seems [NSDate : MCACalendar]?() fails and returns nil. You probably want to use: var dic = [NSDate : MCACalendar]?([:]) or var dic: [NSDate : MCACalendar]? = [:] ...

Rails getting the error: First argument in form cannot contain nil or be empty

ruby-on-rails,ruby,model,nested,nil

You are trying to access @time_delta variable in your stocks/show view, but it is not set. Add the following line to StocksController#show action. @time_delta = @stock.time_deltas.build EDIT: Also there is a problem with the naming of your TimeDelta model, because in Ruby 'delta' is plural of 'deltum'. To adhere to...

Swift URL Reponse is nil

session,swift,return,nsurl,nil

The dataTaskWithURL runs asynchronously. That means that the completionHandler closure will not be called by the time you return from fetchData. Thus, result will not have been set yet. As a result, you should not try to retrieve data synchronously from an asynchronous method. Instead, you should employ an asynchronous...

UIImageView image not returning nil but image not showing

uiimageview,uiimage,nsurl,nlog,nil

It must be that you didn't create the image view when the first time you access the view of UIViewController. Note that self.view will trigger viewDidLoad method if it is nil, but then the imageView is nil. So you'b better create the imageView in viewDidLoad method.

How do I check if an object on Parse is nil, in Swift?

swift,parse.com,nil

You should do something like this, you should learn this format of code. It's the basic of Swift: if let isConnected = user["instagramCredentials"] { instagramIsConnected = true } else { instagramIsConnected = false } You can find a topic called "If Statement and Forced Unwrapping" in the Swift tutorial from...

Global variables have nil value, attempt to call global (a nil value) in Corona

lua,corona,global,nil,value

currently your textlistenerlocation function is not being called. So when you hit the submit button, locationGlobal has not yet been defined. The following looks suspicious: locationTxtbox:addEventListener("textListenerLocation",locationTxtbox) the addEventListener should take an event string and then a function to call when the event happens. textListenerLocation is your event handling function, it...

UIImage returns nil

ios,objective-c,uiimage,nil

I think you are trying to use the imgView.image property even before you set it. imageView.image is being set with this line imgView.image = [info objectForKey:@"UIImagePickerControllerEditedImage"]; Move that line to beginning of the method. like this - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ imgView.image = [info objectForKey:@"UIImagePickerControllerEditedImage"]; if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {...

Get the frame of UITableViewCellAccessoryDetailButton (which is nil)

ios,objective-c,uitableview,nil,accessoryview

You don't need to get the frame to present the popover. When you have an accessory view, the width of the cell's contentView is made narrower so it ends just before the accessory view (you can see this if you give the contentView a background color). You can use that...

form_for: undefined method `new' for nil:NilClass

ruby-on-rails,gem,nil,form-for

The error was due to my gemfile settings. Rails was "locked" to version 4.1.1 whereas other gems were free to update to whatever version they wanted. Updating my gemfile so the Rails version used is 4.1.9 and restarting the app has fixed the issue....

How do I check if there's a nil set or not in an array?

ruby,arrays,nil

any? iterates over a container, like an array, and looks at each element passed to it to see if it passes a test. If one does, the loop stops and true is returned: ary = [nil, 1] ary.any?{ |e| e.nil? } # => true The documentation explains this well: Passes...

NoMethodError in CartsController#destroy - Agile Web Development with Rails 4

ruby-on-rails,ruby-on-rails-4,nil,nomethoderror

Tried from rails console and got this: 2.2.0 :001 > carro = Cart.find(25) Cart Load (12.9ms) SELECT "carts".* FROM "carts" WHERE "carts"."id" = ? LIMIT 1 [["id", 25]] => #<Cart id: 25, created_at: "2015-02-17 01:10:49", updated_at: "2015-02-17 01:10:49"> 2.2.0 :002 > carro.destroy (0.2ms) begin transaction /home/xx/.rvm/gems/ruby-2.2.0/gems/activerecord-4.0.0/lib/active_record/associations/has_many_association.rb:75: warning: circular argument reference...

Where is defined nil in Ruby

ruby,oop,nil

It is defined in keyword.rb file : A special "non-object". nil is, in fact, an object (the sole instance of NilClass), but connotes absence and indeterminacy. nil and false are the only two objects in Ruby that have Boolean falsehood (informally, that cause an if condition to fail). nil serves...

How to remove all 'nil' values from an array?

arrays,lua,nil,lua-table

The most efficient way is probably to create a new table to hold the result. Trying to move values around in the array is likely to have a higher overhead than simply appending to a new table: function destroy() local tbl = {} for I = 1, #Objects do if(DontDestroyThese[Objects[I]]...

NSInvalidArgumentException', reas-[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[4]'

ios,objective-c,nil

The error means you are trying to put nil in the dictionary (which is not allowed). Since you are building the dictionaries with string literals those can't be nil. This means the problem is with one or more of your images. Try this to help find the problem: +(NSArray *)users...

SpriteKit Node gives me nil when subclassed (maybe?) to another node | Swift

ios,swift,sprite-kit,nil

Your player is nil because you are accessing it from the world node, which is empty. By default, the player is a child of scene. You can change this in the scene editor by setting the node's parent property (see Figure 1). Figure 1. SpriteKit Scene Editor's Property Inspector I...

undefined method [] for nil:NilClass when trying to pull a value of a hash - inspect shows it's there

ruby-on-rails,ruby,ruby-on-rails-3,nil

try present..just like we do usually for checking params if @values[:true_value].present? # do some stuff end ...

Why type(nil)==nil is false?

lua,nil

The function type() always returns a string, the value of type(nil) is the string "nil", which is not the same as nil, they have different type.

What is the `zero` value for time.Time in Go?

time,go,nil

Passing no arguments to time.Time will return Go's zero date. Thus, for the following print statement: fmt.Println(time.Time{}) The output is: 0001-01-01 00:00:00 +0000 UTC For the sake of completeness, the official documentation explicitly states: The zero value of type Time is January 1, year 1, 00:00:00.000000000 UTC. ...

Undefined method for NilClass

ruby-on-rails,methods,undefined,nil

Nevermind, all that's needed is to update the server. So close the server and type rails s.

fetchedResultsController core data fatal error: unexpectedly found nil while unwrapping an Optional value

uitableview,swift,core-data,nil,optional-values

You need to set self.managedObjectContext (it is currently nil and that is causing your error). You could set it in one of the functions called early in the life of the view controller, such as viewDidLoad, but another way would be to set it when initialising the fetchedResultsController, like this:...

Return true if certain elements of an array are nil

ruby,arrays,nil

I would do something like this: row[2..-1].all?(&:nil?) ...

Ruby undefined method `pair_push' for nil:NilClass (NoMethodError)

ruby,nil

In the constructor you should use @instance_variables. In your Json class' constructor, when you refer to data, that's just an uninstantiated local variable. You should use @data instead. Same goes for @index: class Json attr_accessor :index,:data def initialize @index=MyMap.new @data=MyMap.new end def create_index(_index, type, id) index.pair_push("_index", _index) index.pair_push("_type", type) index.pair_push("_id",...

What happens if you don't nil-check [super init] and try to initialize nil?

objective-c,initialization,nil,self,super

Partly convention, partly you're right, but it does depend on what you're going to setup using self. In some cases you will be doing a lot of configuration, and creating all of that configuration when it won't actually be used is wasteful. In some cases you may be passing nil...

How to check if a UILabel is empty and append content to a label?

ios,swift,nil

You can use optional binding: if let to check if something is nil. Example 1: if let text = history.text where !text.isEmpty { history.text! += "\ncontent" } else { history.text = digit } Or you can use map to check for optionals: Example 2: history.text = history.text.map { !$0.isEmpty ?...

Handling nil's in Ruby

ruby-on-rails,ruby,nil

Since you are using rails, you can use Object#try, which always returns nil if the object is nil: x = [1,2,3] x.try :map, &->(e) { e+1 } # => [2, 3, 4] x = nil x.try :map, &->(e) { e+1 } # => nil ...

Does NSNumberFormatter.stringFromNumber ever return nil?

swift,nil,nsnumber,optional,nsnumberformatter

My best guess would be because of the legacy support. This is from the official documentation: The behavior of an NSNumberFormatter object can conform either to the range of behaviors existing prior to OS X v10.4 or to the range of behavior since that release. NSNumberFormatter Class Reference ...

Parse query gives nil outside himself

swift,parse.com,nil

I have resolve this by calling this line of code everyvhere where I need data from Parse.com, and everything I need to do, Im doing inside if(!error) statement. It is not maybe officiant way, but it works.

nil __weak self - Why it's happend?

ios,objective-c,block,nil,weak

As rckoenes suggested, this SPHVideoPlayer is falling out of scope and is getting released. Assuming you don't want it to be released, you just have to choose a scope that keeps it around (e.g. making it a property of the view controller that is showing the video). You describe your...

Assign variable as either output of equation OR nil if equation can't run (circumventing NoMethodError)

ruby,if-statement,ruby-on-rails-4,error-handling,nil

How about checking if those params exist instead? @rentalrequest = RentalRequest.new do |rr| rr.delivery_start = nil if request_params[:deliverydate].present? && request_params[:deliverytime_start].present? rr.delivery_start = Time.zone.parse(request_params[:deliverydate] + " " + request_params[:deliverytime_start]).utc end ... end ...

Ruby: A neat way to find the number of non nil records from a Hashie::Mash

ruby,ruby-on-rails-4,salesforce,nil

Try this: restforce_hash.count { |key, val| !val.nil? } ...