displaying a full link using NSLog - ios

Simple question, new to iOS and Objective-C, not understand why it's not doing the full link.
NSLog(#"http://iam.colum.edu/portfolio/api/course/%#", setCourseNumber, "?json=True");
output: http://iam.colum.edu/portfolio/api/course/32-2400
Not going to go into what the coursenumber is, no point, the question is that my output is not including the "?json=True" part of the link. I know it must be something small that I am not including, I just am new to Objective-C and can't figure it out. Thank you in advance.

This:
NSLog(#"http://iam.colum.edu/portfolio/api/course/%#", setCourseNumber, "?json=True");
Could be this:
NSLog(#"http://iam.colum.edu/portfolio/api/course/%#?json=True", setCourseNumber);

Looks like Logan beat me too it.
Here's some more information from Apple's documentation on formatting string objects.
Here's a list of string formats. Things like %#, %d, etc.

Because you have two arguments, but using only one:
NSLog(#"http://iam.colum.edu/portfolio/api/course/%#", setCourseNumber, "?json=True");
setCourseNumber is first attribute - %#
"?json=True" is second attribute - ?
So you can modify it like this:
NSLog(#"http://iam.colum.edu/portfolio/api/course/%#%#", setCourseNumber, "?json=True")
Or use
NSLog(#"http://iam.colum.edu/portfolio/api/course/%#?json=True", setCourseNumber)
No matter, where argument is situated - in the middle or in the end.

Related

How to insert an untitled hyperlink with RestructuredText?

With RestructuredText, I'd just like to insert a link where the address is the text of link. Like this: https://www.example.com/example-of-link.html
I just want the link to appear in the text, with no modification, no title, just the raw link. I can't find a way to do this. All the examples in the doc give titles to the links. Is there a way to do that?
Thanks for your help.
Ok, answering my own question: you just have to write the link and that's it, like this:
https://www.example.com/example-of-link.html
I always seem to forget that and I waste time searching for it. At least now the answer will be on Stackoverflow.

Remove first part of a string that haven't fixed length

I ran into some problems with my code and I don't know how to fix it. So my problem:
On a View of my application, there is a filepath displayed like this:
/resume/attachment/12/yaml_error_complete.yml
But I only want the filename as Output, means:
yaml_error_complete.yml
How can i achieve this? I tried with several options like string.slice! etc, but it doesn't work, since the number after "attachment" is increased by 1 for every single upload. At beginning I thought about to simply remove 2 chars, don't matter what they are. But then i ran into another problem that happens when the 100 file is uploaded. In this case i would have to remove 3 chars instead of 2, and i'm again at the beginning of my problem.
May someone of you can help me?
Thanks a lot!
I assume that you need to retrieve the file of a path.
for ex if your file name is "/resume/attachment/12/yaml_error_complete.yml"
Then try this one
"/resume/attachment/12/yaml_error_complete.yml".split('/').last
If I understand your question right, then, maybe it should help you:
a = "/resume/attachment/12/yaml_error_complete.yml"
a.split('/').last
#=> "yaml_error_complete.yml"
In addition to the sulution with split('/') you could do the following
File.basename("/resume/attachment/12/yaml_error_complete.yml")

How to creat a NSString using copied code snippets from my own app which are then viewed in a TextView control in Objective-C

I a a bit new, but did do a Google search and here on Stack, but with no results that helped me solve this issue. I have taken some Objective-C via Lynda.com courses with Simon Allardice, which were great starting points, but what I need to do is this:
I am writing a simple demo / reference app that has a bunch of controls on the interface (UIButton, UISwitch etc). I also have to the right, a TextView control. When the user touches the button for example, I want to show the code I used to perform the actions in the method as sort of a "how to" or "How I did that" reference for myself.
I have tried:
NSString *myCode = #"copied code snipped into here";
But I get a warning that is not clear to me. I thought that perhaps I needed to use the 'stringWithFormat' method on the NSString, but that did not work out either. So, how can I copy snippets of code into a NSString var so that I can reference it i my app at runtime showing the text in the TextView control?
Thanks
There's nothing special about code. It's just text, and you can easily put it into a string. The only thing you need to watch out for is special characters like quotation marks and line endings. You'll need to escape the quotes with a backslash so that the quotes are interpreted as part of the string rather than the end of the string. Similarly, use an appropriate escape sequence for your line endings.
So, if your code looks like this:
if (self.label) {
self.label.text = #"Hello, world!";
}
you should do something like this:
NSString *codeString = #"if (self.label) {\nself.label.text = #\"Hello, world!\";\n}"

How do I link to a LABEL in org-mode?

In org-mode, I have defined a figure+caption like this:
#+CAPTION: My great figure
#+LABEL: fig:myfigure
[[myfigure.png]]
How do I write "See figure [myfigure]"? I've found the following syntax:
See figure \ref{fig:myfigure}
but this looks ugly in the source file. In particular, you cannot use it for actually jumping to the figure.
You actually don't need '#+NAME', it works fine if you use '#+LABEL', which won't break your short-caption for list of figures.
Orgmode does now offer a 'jumpable', enumerated or link with name of your choice in the exported (latex, html) text if you link with:
see figure [[fig:myfigure]].
or
see figure [[fig:myfigure][figurenameintext]].
I would have added this as a comment, but I don't have the reputation yet.
--
In response to your comment (still can't comment): you do need the '#+NAME' for it to jump within the .org source file; as mentioned in the manual, and i also just confirmed that works. Not sure about the short-captions in the latest version.
With a very recent org-mode, you can use #+name:, see:
http://thread.gmane.org/gmane.emacs.orgmode/62644/focus=62646
#+CAPTION: My great figure
#+LABEL: fig:myfigure
#+name: fig:myfigure
[[test.png]]
See figure [[fig:myfigure][test]].
This works for me to jump from the link , but has no effect when exporting, I'm afraid...

Is there anything called Execute Non Scalar

Is there anything called ExecuteNonScalar ? in any of the programming language.
No. But there is ExecuteNonQuery, and ExecuteScalar.
Well there is a method called "ExecuteScalar" in .NET. It basically returns the first column of first resultant row.
For more info and example you may check this: link

Resources