3
votes
3answers
80 views

When are argument labels required in Swift?

In answering this question it came about that argument labels were required for a call to init. This is normal in Swift. class Foo { init(one: Int, two: String) { } } let foo = Foo(42, "Hello ...
0
votes
2answers
58 views

^(){} syntax in Objective C

I have seen some strange syntax like self.myProperties = ^(){}; I wonder what is meaning of this ?
0
votes
1answer
26 views

self with two arguments using dot syntax

I have looked through a lot of questions and I am still unable to understand this syntax in Big Nerd Ranch. -(void) setContainedItem:(BNR *)containedItem { _containedItem = containedItem; ...
-1
votes
1answer
33 views

How can this code compile? [closed]

const UIView * vLocalBottomButton = self.BottomButton; vLocalBottomButton =nil; Basically I want to pass on self.BottomButton to a method that will run at outside the main thread. When the ...
0
votes
1answer
33 views

how to access single JSON value for key in Objective-C

I am new to Obj-C and somehow I can get the output of a JSON-Request due to difficulties with arrays, dictionareis and syntax. It would be great if someone could get me on my way. NSLog(@"JSON ...
0
votes
1answer
182 views

Protocol vs Interface [duplicate]

I've been reading the swift documentation, and working through the playground. I have to admit I have zero knowledge of Objective-C/iOS development (outside of Xamarin at least). To my eyes, a ...
0
votes
1answer
26 views

Declaration of type in parentheses when assigning [duplicate]

Sometimes I see examples code like this: RootViewController *rootViewController = (RootViewController *)[navigationController topViewController]; Where RootViewController is a specific class that ...
0
votes
1answer
66 views

What does “[self data][date]” mean?

Can any one just tell me what the below code in iOS mean? Its a piece of code from MBCalendarKit. @property (nonatomic, strong) NSMutableDictionary *data; - (NSArray *)calendarView:(CKCalendarView ...
4
votes
1answer
54 views

What is “the issue” with variable qualifier placement?

In this document, under the section labeled "Variable Qualifiers", Apple says: You should decorate variables correctly. When using qualifiers in an object variable declaration, the correct format ...
8
votes
2answers
379 views

Why does Objective-C use square brackets for messages?

I'm reading a book about Smalltalk (Charmond Liu's Smalltalk, Objects and Design). He talks about how messages work in Smalltalk using a HomeBudget object as an example of how to send a single message ...
0
votes
3answers
36 views

Explaning syntax for @property id<delegateName>

I see a lot of code references when writing delegates using something likes @property (nonatomic, weak) id<mySuperCoolDelegate> delegate; normally where id<mySuperCoolDelegate> is, is ...
-1
votes
1answer
32 views

How to assign a value to a double bracketed expression in Objective C

Specifically, how can I rewrite the following example of dot syntax to the equivalent bracket syntax: cell.textLabel.text = @"This is a cell"; I thought it would look something like this: [[cell ...
1
vote
1answer
92 views

What is this double curly brace in C, Objective-C

In reference to this source code what is the purpose of the double curly braces within the @autoreleasepool? int main(int argc, const char * argv[]) { @autoreleasepool { {{ ...
1
vote
1answer
50 views

What's the correct way to declare a __block variable?

Should I declare it as (#1) ClassName * __block variableName or (#2) __block ClassName * variableName ? I seen a lot of code uses format #2, Including Apple's Blocks Programming Topics. But ...
-5
votes
2answers
67 views

Why do some people put the asterisk next to the type name and some next to the variable name?

I'm confused about the following ways of declaring a pointer. They seem the same to me, but I have seen developers write both ways. ClassName* instancevariable; ClassName *instancevariable; Is ...
0
votes
2answers
77 views

Error “Property setVariableName not found” using dot notation to set property

I've just started learning Objective-C and I'm not sure when to use dot notation vs. square brackets. I know a similar question has been asked here but I'm still not really understanding the ...
0
votes
1answer
42 views

Is it safe to assume that leading underscores are ignored when using the dot syntax

Quick question. All of the courses that teach objective C that I have participated in always prefix their instance variables with an underscore. They also explain that when using the dot syntax that ...
0
votes
1answer
58 views

block not being called on the other end

i'm new to blocks, I have a class of requests with static methods to call me back on UIViewControllers with some blocks this is the method implementation : (putting a breakpoint on the ...
1
vote
1answer
70 views

Why is Objective-C block syntax so different from method syntax?

The question says it all. Why: (void)methodWithParamA:(id)paramA paramB:(id)paramB; [obj methodWithParamA:valA paramB:valB]; and: void(^ block)(id paramA, id paramB); block(valA, valB); I'm not ...
0
votes
2answers
61 views

Objecive c propreties and private variable

I'm a debutant to objective-c and I don't understand something. I practiced c++ so some practices are not instinctif .. 1) @implementation Car { // Private instance variables double ...
7
votes
1answer
95 views

Assignment of several statements enclosed in parentheses and curly braces in ObjC [duplicate]

I was perusing the code of the third-party RESideMenu framework, and noticed some strange syntax that seemed to work just fine. Here is the confusing bit: self.tableView = ({ UITableView ...
0
votes
1answer
42 views

Declare an Objective-C method with multiple arguments

I would like to pass NSTask (NSTask, launchpath, and the args) to a function, but sure I need some help with the semantic: AppleDelegate.h file: - (void)doTask:(NSTask*)theTask :(NSArray*)arguments ...
-2
votes
2answers
66 views

Calling functions in C-like syntax [closed]

How can I write code in Xcode max similar to syntax in Java or C++ in particular call functions (messages), static or dynamic? I just want to simply call Objective-C function in C-like syntax. How ...
0
votes
0answers
44 views

What characters can be used in an objective-c method?

What characters can use use in an objective-c method? I know that you can use the Latin alphabet as well as + - ( ) : ; *, where the symbols are reserved. But are there other characters you can use? ...
-1
votes
3answers
79 views

Objective-C properly setting Instance Variables Syntax

Hi for starters let me say thank you for helping me out on this problem. I'm currently trying to learn Objective-C. I first started learning Java in AP Computer Science (taught at my High School) ...
0
votes
1answer
44 views

What does it mean (Class *)?

Example: - (Subclass *)field:(NSArray *)fields { // code return (Subclass *)[self field:fields]; } I've seen more than once where it is used (Class *). So, what does it mean?
0
votes
2answers
60 views

Create a date from a string

I'm pretty comfortable with core data now (only been iOS Developer for 6 months) but I haven't come upon having to put a date in core data. So here's the situation. I'm pulling data from a web ...
0
votes
1answer
60 views

Plotting hits within given areas of circle - Code for setup getting bloated

[Alternative approach given by user1118321, old and new code listed for reference] I am busy writing a small app which allows a game of darts 501 to be scored. I have set up a class to contain the ...
0
votes
1answer
121 views

typedef with same name in different classes Objective-C

I have this typedef: //MyClass_1.h typedef enum { edit, copy, paste } textAction; and when I want this typedef in MyClass_2.h: //MyClass_2.h typedef enum { edit, copy, paste } ...
0
votes
1answer
132 views

Variable definition inside switch-case [duplicate]

#pragma mark AlertView delegate - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSUserDefaults *userdefault=[NSUserDefaults standardUserDefaults]; ...
0
votes
2answers
67 views

What is wrong with writing MyClass.alloc and MyClass.class in Objective C?

The compiler seems to be happy, I'm happy with slightly improved readability, but Xcode's code completion doesn't particularly recognize alloc and class when invoked this way: MyClass* object = ...
-1
votes
3answers
130 views

Bracket syntax in Objective-C [duplicate]

I like to mess with coding every now and then as a hobby and I noticed an unfamiliar syntax in some of the Apple Developer documentation: newSectionsArray[index] I normally expect something like: ...
0
votes
3answers
27 views

How should I be sending a message with a field of the same object as its value?

In Objective-C, the compiler is complaining about the following line of code: if ([self getLength(self.identifier)] < givenWidth * kMarginAllowance) This is getting the error "Expected ']'", and ...
1
vote
3answers
91 views

Objective C syntax differences

I came across this kind of syntax a while ago : [myView setFrame:({ CGRect frame = myView.frame; frame.size.height = heightValue; frame; })]; I can't remember where I saw this, but I ...
2
votes
3answers
158 views

Never before seen syntax in Objective-C: open/close braces w/out method/conditional statement, what is the purpose?

I am looking over an Xcode project I downloaded and am seeing code syntax that I am unfamiliar with: The braces don't belong to a method signature, or any other conditional statement, they are just ...
-1
votes
5answers
260 views

Method Syntax Clarification in Objective-C

Consider the below prototype, which is a common one, -(void)writeData:(NSData *)data length:(NSInteger *)len; I am aware what each part of this method means. My query is, whether the "length", the ...
0
votes
2answers
115 views

Declaring a method that takes a Block [duplicate]

I'm trying to figure out how to declare a method that takes a block as an argument and just logs an integer value from the outside scope. Most examples I see are doing this on some Apple API like ...
0
votes
1answer
56 views

objective-C '$' notation [duplicate]

I'm still new to objective-c I went through a code example from git hub and saw '$' notation before parameters for example: titleLabel.$height = TITLE_HEIGHT; can some one explain the difference ...
0
votes
3answers
761 views

What does typedef enum syntax like '1 << 0' mean? [duplicate]

I'm somewhat familiar with the typedef enum syntax of C and C++. I'm now programming in Objective-C and came across the syntax in the following example. I'm not sure if the syntax is Objective-C ...
-2
votes
2answers
74 views

Objective C Calling Method Syntax [duplicate]

I'm a bit confused on how methods are called and the syntax behind it. Can someone dissect two lines of code for me? I've got a bunch of random questions. NSString *testString; testString = ...
1
vote
1answer
338 views

objective-c multi protocols in one class correct syntax

I've a main class where I want to define two protocols (1 used by a class A, the other by class B) (ios 6.1, xcode 4.6.3 , ARK mode, storyboard project). According to official syntax, all my code ...
0
votes
0answers
88 views

Writing Hex To Console Using NSString

I'm trying to write all the hex values, from 0 - 255 in a for loop. It's not printing in hex. I think the %x is what is causing the issue. int i=0; for (i = 0; i < 256; i++) { [_d ...
0
votes
1answer
170 views

Syntax highlighting on iOS 6

Is there fast and simple way to highlight text on iOS 6? I need to create an Objective-C editor on iOS 6 and I think that NSAttributedString is enough. I think that I need the definition of ...
1
vote
2answers
311 views

SimpleStocks protocol usage (Apple sample code)

In the SimpleStocks sample code provided by Apple, dataSource is defined as follows: property (nonatomic, weak) IBOutlet id <APLSimpleStockViewDataSource> dataSource; and then used variously ...
0
votes
3answers
121 views

Duplicate Method Issue

I'm very new to Objective-C and the syntax and everything. I wrote two separate methods, but ran into the error: Duplicate declaration of method webView:shouldStartLoadWithRequest:navigationType: So, ...
1
vote
2answers
130 views

Objective-C protocol syntax

Here are 2 lines of code from Apple's own SimpleStocks sample code (APLSimpleStockView.m) NSInteger dataCount = [self.dataSource graphViewDailyTradeInfoCount:self]; NSArray *sortedMonths = ...
1
vote
2answers
121 views

What is the function of “(ClassName *)”

I have seen code statements that use '(ClassName *)' to reference certain objects, like in UITableViewCell *myCell = (UITableViewCell*)[self.view viewWithTag:1];. I have no idea what this means or ...
3
votes
1answer
88 views

Method with variable arguments followed by non-varargs

I get that you can do something like this: +(id) objectWithItems: (NSObject *) item, ...; However I was wondering if it was possible to do something like this (I cannot get this to compile): ...
1
vote
1answer
669 views

I need a windows objective-c programming IDE that checks syntax and warns errors

I need a programming IDE for windows and objective-c. It doesn't need to compile and run or anything like that, but I really need it to check my code, and make sure it's legitimate. After hours of ...
3
votes
4answers
179 views

Objective-C Variable Declaration Confusion

I am confused as to why I am allowed to do this (the if statement is to just show scope): int i = 0; if(true) { float i = 1.1; } I have a c# background and something like this is not allowed. ...