Custom macro for NSLocalizedString [duplicate] - iphone

This question already has answers here:
Custom NSLocalizedString?
(7 answers)
Closed 9 years ago.
This question is regarding the localization from inside the app.
There are several blogs/tutorials that really helps and show the way to do it.
The ones which i referred to implement it are as below:
http://learning-ios.blogspot.in/2011/04/advance-localization-in-ios-apps.html
http://www.pastie.org/1976594
I am able to achieve it (with the help of such blogs.. thanks to them).
But i was trying one thing and i had a little doubt regarding the same as below
I am trying to create a same macro as the NSLocalizedString
[i.e. NSString *NSLocalizedString(String *key, String *value)]
but with a different macro name
something like
[NSString *getLocalizedString(String *key, String *value)] in my class and try to just replace NSLocalizedString method with my own macro using the same.
But a serious doubt/concern that i have is, is this technique/way approved by APPLE?
i mean.. can/will this violate the apple terms of non usage of Private API or kind of overriding the same??
Coz i have tried check the same in various blogs.. but was not able to find any specific answer to the same.
Can you please confirm if this can violate the T&C of APPLE or can i go ahead with the custom macro approach?
If possible can u also provide the link/blog/tutorial from which i can understand it better?
Thanks a lot in advance.

I don't see how this is using any kind of private APIs. -[NSBundle localizedStringForKey:] is a public API. You can write whatever macros or functions you want that call it. You can even #undef NSLocalizedString and replace it with your own definition if you want, it's just a C macro.

This won't violate Apple's terms. In fact, they recommend you do this to test your app and make sure you translated all the strings. They demonstrated how to do this in the 2012 WWDC video, session 244 Internationalization Tips and Tricks at the 23:50 mark.

Related

Attribute weak extern in Swift

I'm converting the obj-c framework to the Swift one.
I need to convert this line:
__attribute__((weak)) extern NSString *sdkVersion = 0;
to Swift similar one. Spend a lot of time on google, but didn't find the answer.
Predicting your questions, what I'm trying to achieve... in short words, this global variable is defined in an optional framework. My Swift function should print this version in case if our SDK is linked with that framework.
I know, I can create a wrapper (another objc framework), add necessary getters there, and then link it with the main framework. But may be there is a more simple solution?
Thanks in advance.

Swift 4 .symmetricDifference and others are not working

First coding question ever!
So I'm totally new at coding and I'm taking a course in Lynda.com
The course is for swift 4 but there are certain commands that are not working or I have to write it different in order for it to work.
For example
Course says: activeQuest.sorted() Does not work
activeQuest.sort() Does work
Course says: activeQuest.intersection(completedQuests) Does not work
activeQuest.intersect(completedQuests) Does work
.symmetricDifference does not work and couldn't find any other way to write it
Why is this? Thank you!
Why is this?
It’s because the course is for Swift 4 but you are using an earlier version of Swift.

How can I check the embedded functions definitions in swift?

I am learning Swift by myself on MacOS. When following the tutorial and practicing the array function: <array_name>.sort(), I can get it executed but I always wonder how it works and what is the actual algorithm inside it.
So is there any way to check the certain function definitions?
If you want to check the declaration of the function/class, you can command-click on it. If you want the documentation, you can either option-click it or check it on the API reference page. If you want to see the implementation details of the Swift standard library, check the source code here at GitHub. If the implementation you are checking is in a non open-source APIs though, you can't quite check it.

Is it possible to write inline assembly in Swift?

I was wondering if you can write inline assembly in Swift.
I know that in Objective-C you could use something like this:
inline void assemblyFunc() {
__asm__(/*Assembly*/);
}
But in Swift it seems that you can't use __asm__(/*Assembly*/).
Does anyone know how to use __asm__() if its even possible.
I haven't found anything about it, so I thought it would be a good question to ask.
There isn't a way in Swift itself. If you need this, probably a good opportunity to take advantage of Swift-ObjC interop.
To expand on what Robert Levy said, you can just use the Swift/Obj-C interop feature, and write an Obj-C class that does the ASM stuff, which you can then call from Swift.
It's an annoying workaround, but it should work nonetheless.
You can read more about how to do it [here]

Getting warning while uploading application on Apple app store [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am new to this technology.
I am getting following warning while uploading application from Application Loaded.
Warning says "The app references non-public selectors in "App Name" instance, viewController"
Please help me solve this warning.
Thanks in advance!
EDIT
Image :-
EDIT :-
Will my application get approve?
Use App Scanner. It analyzes your .app file for private API method usage.
It will catch methods that have been named the same as a private API method, even if it has it's own implementation. Also, it'll catch #selectors inside methods (just like the official iOS automated checker).
App Scanner doesn't catch the case when performSelector: is called with a selector that is a private method. However, Apple's tools do catch that case.
Another Alternative APP Kit, though I haven't used it. Give it a try.
Check out this Q&A, if you haven't. How does Apple know you are using private API?. Looks Helpful.
What was the last thing you added to the code before you got this error? The error means you have a private API call, as my link above notes.
If you dont think it was your code, then it might be any of the included code.
#iPhoneDev: i guess your application will not be rejected due to this reason. Because i have faced this warning in one of my app, and it was accepted successfully. So no need to worry
I think you might have a function named instance somewhere in your code, such as:
+(id)instance{
return something;
}
.. maybe a singleton implementation? If this is the case, just rename it.
I've seen apps approved despite the fact that they triggered similar alarms, but why would you want to risk a rejection?
Search for viewController in your entire project and search if there is any singleton implementation.
Even if Apple approve you application, its not good to have non-public sectors in your application.
You can also use App Scanner
Hope it helps you
Almost certainly get rejected for this.
Just a guess, but search for "viewController" and see if you are referencing a private instance method, or perhaps a private instance variable via dot notation: .viewController
No, your app will be rejected like this. Definitely. Apple review team uses the same checks as Xcode plus a few more.