In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you what are the useful little knowledge points about IOS development. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Get the system language settings
NSUserDefaults * userDefault = [NSUserDefaults standardUserDefaults]
NSArray * languages = [userDefault objectForKey:@ "AppleLanguages"]
NSString * preferredLang = [languages objectAtIndex:0]
2. File size under cache path
-(unsigned long long int) cacheFolderSize
{
NSFileManager * _ manager = [NSFileManager defaultManager]
NSArray * _ cachePaths = NSSearchPathForDirectoriesInDomains (NSCachesDirectory
NSUserDomainMask, YES)
NSString * _ cacheDirectory = [_ cachePaths objectAtIndex:]
NSArray * _ cacheFileList
NSEnumerator * _ cacheEnumerator
NSString * _ cacheFilePath
Unsigned long long int _ cacheFolderSize =
_ cacheFileList = [_ manager subpathsAtPath:_cacheDirectory]
_ cacheEnumerator = [_ cacheFileList objectEnumerator]
While (_ cacheFilePath = [_ cacheEnumerator nextObject])
{
NSDictionary * _ cacheFileAttributes = [_ managerfileAttributesAtPath:
[_ cacheDirectory stringByAppendingPathComponent:_cacheFilePath]
TraverseLink:YES]
_ cacheFolderSize + = [_ cacheFileAttributes fileSize]
}
/ / the unit is in bytes
Return _ cacheFolderSize
}
3. Frame cannot change the solution during Popover push
Implemented in ViewController in popover:
-(void) viewWillAppear: (BOOL) animated
{
CGSize size = CGSizeMake (320,480); / / size of view in popover
Self.contentSizeForViewInPopover = size
[super viewWillAppear:animated]
}
4. Solution to stop NSTimer and delegate callback caused by tableview sliding
/ / request callback
NSURLRequest * request =.
ScheduleInRunLoop: [NSRunLoop currentRunLoop]
ForMode: NSRunLoopCommonModes]
[connection start] / / timer callback
NSTimer * updateTimer = [NSTimer scheduledTimerWithTimeInterval:0.01f goal: self-choice: choice (updatePencent) UserInfo: no repetition: yes]
* NSRunLoop mainly = [NSRunLoop currentRunLoop]
[primary addTimer:updateTimer forMode:NSRunLoopCommonModes]
5. Gesture recognition
UIGestureRecognizer
6. SFHFKeychainUtils stores information
Apple SDK comes with password protection. It is easy to use, as follows:
1. Introduce Security.frameWork framework.
2. Import header file: SFHKeychainUtils.h.
3. Deposit password:
[SFHFKeychainUtils storeUsername:@ "dd" andPassword:@ "aa" forServiceName:SERVICE_NAMEupdateExisting:1 error:nil]
[SFHFKeychainUtils deleteItemForUsername:@ "dd" andServiceName:SERVICE_NAME error:nil]
4. Get the password:
NSString * passWord = [SFHFKeychainUtils getPasswordForUsername:@ "dd" andServiceName:SERVICE_NAMEerror:nil]
7. Missing required architecture i386 in file solution
Just modify the Framework Search Pasths and delete the contents in TargetInfo.
8. View zooms in and out of animation effects
/ / create a scaled-out view
MyWeiBoImageVC = [[UIViewController alloc] init]
MyWeiBoImageVC.view.clipsToBounds = YES
MyWeiBoImageVC.view.alpha = 0.0
MyWeiBoImageVC.view.frame = CGRectMake (64, 0, 1024-64768-20)
[self.view addSubview:myWeiBoImageVC.view]
CGAffineTransform newTransform =
CGAffineTransformScale (myWeiBoImageVC.view.transform, 0.1,0.1)
[myWeiBoImageVC.view setTransform:newTransform]
MyWeiBoImageVC.view.center = CGPointMake (670,100)
[self performSelector:@selector (p_w_picpathViewControllerBigAnimation)]
/ / Zoom in on the view just created after zooming out
-(void) p_w_picpathViewControllerBigAnimation {
[UIView beginAnimations:@ "p_w_picpathViewBig" context:nil]
[UIView setAnimationDuration:0.5]
CGAffineTransform newTransform = CGAffineTransformConcat (myWeiBoImageVC.view.transform, CGAffineTransformInvert (myWeiBoImageVC.view.transform))
[myWeiBoImageVC.view setTransform:newTransform]
MyWeiBoImageVC.view.alpha = 1. 0
MyWeiBoImageVC.view.center = CGPointMake (416,510)
[UIView commitAnimations]
}
/ / zoom out to hide the view
-(void) p_w_picpathViewControllerSmallAnimation {
[UIView beginAnimations:@ "p_w_picpathViewSmall" context:nil]
[UIView setAnimationDuration:0.5]
CGAffineTransform newTransform = CGAffineTransformScale (myWeiBoImageVC.view.transform, 0.1,0.1)
[myWeiBoImageVC.view setTransform:newTransform]
MyWeiBoImageVC.view.center = CGPointMake (670,100)
[UIView commitAnimations]
}
9. UIScrollView controls View scaling
AllImageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake (0,0,768,1024)]
AllImageScrollView.minimumZoomScale = 0.3
AllImageScrollView.maximumZoomScale = 1. 0
AllImageScrollView.backgroundColor = [UIColor clearColor]
AllImageScrollView.delegate = self
[self.view addSubview:allImageScrollView]
MPicStatusesViewController = [[PicStatusesViewController alloc] init]
[allImageScrollView addSubview:mPicStatusesViewController.view]
/ / UIScrollView Delegete implementation
-(UIView *) viewForZoomingInScrollView: (UIScrollView *) scrollView
{
Return mPicStatusesViewController.view; / / returns the view added on the ScrollView that needs to be zoomed
}
-(void) scrollViewDidZoom: (UIScrollView *) scrollView
{
/ / the zoom operation is called
}
-(void) scrollViewDidEndZooming: (UIScrollView *) scrollView withView: (UIView *) view atScale: (float) scale
{
/ / called after zooming is finished
}
10. IOS3.2 plays videos
NSString * urlString = [NSString stringWithString:@ "Video url"]
NSURL * movieUrl = [[NSURL alloc] initWithString:urlString]
MPMoviePlayerController * myMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUrl]
MyMoviePlayer.view.frame = CGRectMake (250,250,350350)
[self.view addSubview:myMoviePlayer.view]
MyMoviePlayer.shouldAutoplay = YES
MyMoviePlayer.scalingMode= MPMovieScalingModeAspectFit
[myMoviePlayer play]
11. Google Maps turns over the animation effect
CATransition * animation = [CATransition animation]
[animation setDelegate:self]
[animation setDuration:0.35]
[animation setTimingFunction:UIViewAnimationCurveEaseInOut]
If (! curled) {
Animation.type = @ "pageCurl"
Animation.fillMode = kCAFillModeForwards
Animation.endProgress = 0.40
} else {
Animation.type = @ "pageUnCurl"
Animation.fillMode = kCAFillModeBackwards
Animation.startProgress = 0.30
}
[animation setRemovedOnCompletion:NO]
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1]
[self.view.layer addAnimation:animation forKey:@ "pageCurlAnimation"]
12. Add shadows and borders to View
UIImageView * imgvPhoto = [UIImageView alloc] init]
/ / add a border
CALayer * layer = [_ imgvPhoto layer]
Layer.borderColor = [[UIColor whiteColor] CGColor]
Layer.borderWidth = 5.0f
/ / add four edge shadows
_ imgvPhoto.layer.shadowColor = [UIColor blackColor] .CGColor
_ imgvPhoto.layer.shadowOffset = CGSizeMake (0,0)
_ imgvPhoto.layer.shadowOpacity = 0.5
_ imgvPhoto.layer.shadowRadius = 10.0
/ / add two edge shadows
_ imgvPhoto.layer.shadowColor = [UIColor blackColor] .CGColor
_ imgvPhoto.layer.shadowOffset = CGSizeMake (4,4)
_ imgvPhoto.layer.shadowOpacity = 0.5
_ imgvPhoto.layer.shadowRadius = 2.0
13. Use NSTimer and UIView animation to achieve snow effect.
In the viewDidLoad event, add a picture and timer and start it. The pic here is defined in the header file.
-(void) viewDidLoad {
[super viewDidLoad]
Self.pic = [UIImage paired picpathNamedsaw @ "snow.png"]; / / initialize the picture
/ / start the timer to achieve the snow effect
[NSTimer scheduledTimerWithTimeInterval: (0.2) target:self selector:@selector (ontime) userInfo:nil repeats:YES]
}
Then implement the ontime method called by the timer:
-(void) ontime {
UIImageView * view = [[UIImageView alloc] initWithImage:pic]; / / declare a UIImageView object to add pictures
View.alpha = 0.5 alpha / set the alpha of this view to 0.5, translucent
Int x = round (random () 20); / / randomly get the x coordinates of the picture.
Int y = round (random () 20); / / this is the last coordinate x-axis of the picture.
Int s = round (random ()) + 10 Snowflake / this defines the size of the snowflake image
Int sp = 1/round (random () 0) + 1 position / this is the speed
View.frame = CGRectMake (x,-50, s, s); / / size and position of snowflake start
[self.view addSubview:view]; / / add the view
[UIView beginAnimations:nil context:view] / / start animation
[UIView setAnimationDuration:10*sp] / / set speed
View.frame = CGRectMake (y, 500, s, s); / / set the final vanishing coordinates of the snowflake
[UIView setAnimationDelegate:self]
[UIView commitAnimations]
}
14. Configure Xcode to see the program crash information
1. Find Executables in the left directory in xcode and open it.
2. Double-click the same file as the project name.
3. In the Arguments option in the open file, add Name: NSZombieEnabled to set value to YES in the box below.
15. Send mail and check whether the device mailbox is configured in the program
-(void) addEmail {
Class mailClass = (NSClassFromString (@ "MFMailComposeViewController"))
If (mailClass! = nil) {
If ([mailClass canSendMail]) {
[self displayComposerSheet]
} else {
[self launchMailAppOnDevice]
}
} else {
[self launchMailAppOnDevice]
}
}
-(void) displayComposerSheet
{
MFMailComposeViewController * controller = [[MFMailComposeViewController alloc] init]
Controller.navigationBar.tag = 1002
[self.navigationController.navigationBar setNeedsDisplay]
Controller.mailComposeDelegate = self
[controller setSubject:@ "opinion feedback"]
[controller setToRecipients: [[NSArray alloc] initWithObjects:@ "555@cifco.net.cn", nil]]
NSString * emailBody = nil
[controller setMessageBody:emailBody isHTML:YES]
[self presentModalViewController:controller animated:YES]
[controller release]
}
# pragma mark mailComposeDelegate-
-(void) mailComposeController: (MFMailComposeViewController*) controller didFinishWithResult: (MFMailComposeResult) result error: (NSError*) error
{
If (result = = MFMailComposeResultSent)
{
[self dismissModalViewControllerAnimated:YES]
}
If (result = = MFMailComposeResultSaved)
{
[self dismissModalViewControllerAnimated:YES]
}
If (result = = MFMailComposeResultFailed)
{
Emailalert = [[UIAlertView alloc] initWithTitle:@ "" message:@ "failed to send" delegate:selfcancelButtonTitle:@ "knows" otherButtonTitles:nil]
[Emailalert show]
}
If (result = = MFMailComposeResultCancelled)
{
[self dismissModalViewControllerAnimated:YES]
}
}
-(void) alertView: (UIAlertView *) alertView clickedButtonAtIndex: (NSInteger) buttonIndex
{
If (alertView = = Emailalert)
{
If (buttonIndex = =)
{
[self dismissModalViewControllerAnimated:YES]
}
} else
{
If (buttonIndex = =)
{
/ / [self dismissModalViewControllerAnimated:YES]
} else
{
NSString * recipients = @ "mailto:theonelgq@gmail.com?cc=theone_liuguoqing@163.com&subject=text"
NSString * body= @ "& body=text!"
NSString * email = [NSString stringWithFormat:@ "% @% @", recipients, body]
Email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:email]]
}
}
}
# pragma mark-
# pragma mark Workaround
-(void) launchMailAppOnDevice
{
IsEmailalert = [[UIAlertView alloc] initWithTitle:@ "warning" message:@ "Please configure your mailbox" delegate:selfcancelButtonTitle:@ "to cancel" otherButtonTitles:@ "OK, nil]
[isEmailalert show]
}
16. Program startup screen size
IOS devices now have three different resolutions: iPhone 320x480, iPhone 4 640x960, and iPad 768x1024. In the past, the startup screen (picture) of the program only needed to prepare a Default.png, but now it has become much more complicated. Here is the summary made by CocoaChina members.
If a program supports both iPhone and iPad, it needs to include the following images:
Default-Portrait.png iPad dedicated vertical boot screen 768x1024 or 768x1004
Default-Landscape.png iPad dedicated horizontal launch screen 1024x768 or 1024x748
Default-PortraitUpsideDown.png iPad dedicated vertical startup screen (Home button is on top of the screen), 768x1024 or 768x1004 can be omitted
Default-LandscapeLeft.png iPad dedicated horizontal startup screen, 1024x768 or 1024x748 can be omitted
Default-LandscapeRight.png iPad dedicated horizontal startup screen, 1024x768 or 1024x748 can be omitted
Default.png iPhone startup images by default. If the above iPad-specific startup images are not provided, Default.png (not recommended) 320x480 or 320x460 will also be used when running on iPad.
Default@2x.png iPhone4 starts picture 640x960 or 640x920
In order to use the above splash screen on iPad, you also need to add key: UISupportedInterfaceOrientations to info.plist. At the same time, add values UIInterfaceOrientationPortrait, UIInterfacOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight
17. ASIHTTPRequest implements breakpoint download
-(IBAction) URLFetchWithProgress: (id) sender
{
[startButton setTitle:@ "Stop" forState:UIControlStateNormal]
[startButton addTarget:self action:@selector (stopURLFetchWithProgress:) forControlEvents:UIControlEventTouchUpInside]
NSString*tempFile = [NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@ "MemexTrails_1.0b1.zip.download"]
If ([[NSFileManager defaultManager] fileExistsAtPath:tempFile]) {
[[NSFileManager defaultManager] removeItemAtPath:tempFile error:nil]
}
[self resumeURLFetchWithProgress:self]
}
-(IBAction) stopURLFetchWithProgress: (id) sender
{
NetworkQueue = [[ASINetworkQueue alloc] init]
Timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:selfselector:@selector (updateBandwidthUsageIndicator) userInfo:nil repeats:YES]
Timer = nil
[startButton setTitle:@ "Stop" forState:UIControlStateNormal]
[startButton addTarget:self action:@selector (URLFetchWithProgress:) forControlEvents:UIControlEventTouchUpInside]
[networkQueue cancelAllOperations]
[resumeButton setEnabled:YES]
}
-(IBAction) resumeURLFetchWithProgress: (id) sender
{
[resumeButton setEnabled:NO]
[startButton setTitle:@ "Start" forState:UIControlStateNormal]
[startButton addTarget:self action:@selector (stopURLFetchWithProgress:) forControlEvents:UIControlEventTouchUpInside]
[networkQueue cancelAllOperations]
[networkQueue setShowAccurateProgress:YES]
[networkQueue setDownloadProgressDelegate:progressIndicator]
[networkQueue setDelegate:self]
[networkQueue setRequestDidFinishSelector:@selector (URLFetchWithProgressComplete:)]
ASIHTTPRequest*request= [ASIHTTPRequest alloc] initWithURL: [NSURLURLWithString:@ "http://9991.net/blog/mp3/2.mp3"]] autorelease]
[request setDownloadDestinationPath: [NSBundle mainBundle] bundlePath]
StringByDeletingLastPathComponent] stringByAppendingPathComponent:@ "MemexTrails_1.0b1.mp3"]]
[request setTemporaryFileDownloadPath: [NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@ "MemexTrails_1.0b1.zip.down"]]
[request setAllowResumeForFileDownloads:YES]
[networkQueue addOperation:request]
[networkQueue go]
}
-(void) URLFetchWithProgressComplete: (ASIHTTPRequest *) request
{
If ([request error]) {
FileLocation.text= [NSString stringWithFormat:@ "An error occurred:%@", [requesterror] userInfo] objectForKey:@ "Title"]]
} else {
FileLocation.text= [NSString stringWithFormat:@ "File downloaded to% @", [requestdownloadDestinationPath]]
}
[startButton setTitle:@ "Start" forState:UIControlStateNormal]
[startButton addTarget:self action:@selector (URLFetchWithProgress:) forControlEvents:UIControlEventTouchUpInside]
}
-(IBAction) throttleBandwidth: (id) sender
{
If ([(UIButton *) sender state] = = YES) {
[ASIHTTPRequest setMaxBandwidthPerSecond:ASIWWANBandwidthThrottleAmount]
} else {
[ASIHTTPRequest setMaxBandwidthPerSecond:]
}
}
18. Safari starts local app
Add the URL types structure to the plist file as shown in the following figure, and enter the set string in the address bar of Safari, such as the
QQ, enter QQ:// in the address bar to start the local application.
19. Drag to video progress and slide gesture conflict resolution
# pragma mark-
# pragma mark UIGestureRecognizerDelegate
-(BOOL) gestureRecognizer: (UIGestureRecognizer *) gestureRecognizer shouldReceiveTouch: (UITouch *) touch
{
UIView * touchView = touch.view
If ([touchView isKindOfClass: [UISlider class]])
{
Return NO
}
Else
{
Return YES
}
}
20. Methods for creating and saving Cookie
NSString * cookieString = [NSString stringWithString: [headers objectForKey:@ "Cookie"]]
NSMutableDictionary * cookieProperties = [[NSMutableDictionary alloc] init]
[cookieProperties setValue:cookieString forKey:NSHTTPCookieValue]
[cookieProperties setValue:@ "QQCookie" forKey:NSHTTPCookieName]
[cookieProperties setValue:@ ".QQ.com" forKey:NSHTTPCookieDomain]
[cookieProperties setValue: [NSDate dateWithTimeIntervalSinceNow:60*60] forKey:NSHTTPCookieExpires]
[cookieProperties setValue:@ "/" forKey:NSHTTPCookiePath]
NSHTTPCookie * newcookie = [[NSHTTPCookie alloc] initWithProperties:cookieProperties]
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:newcookie]
21. The solution to change the position of popover horizontal and vertical screen
1. Processing in delegate
-(void) popoverControllerDidDismissPopover: (UIPopoverController *) popoverController
{
UserImageShow = NO
If ([popoverController isEqual:myPopover])
{
[myPopover release]
MyPopover = nil
}
}
2. Popover pops up again when the screen is rotated
If (myPopover)
{
If ((self.interfaceOrientation = =
UIInterfaceOrientationLandscapeLeft) | | (self.interfaceOrientation = =
UIInterfaceOrientationLandscapeRight))
{
[myPopover presentPopoverFromRect:CGRectMake (100.180, 1,1)
InView:self.view
PermittedArrowDirections:UIPopoverArrowDirectionRight
Animated:YES]
}
Else
{
[myPopover presentPopoverFromRect:CGRectMake (200.180, 1,1)
InView:self.view
PermittedArrowDirections:UIPopoverArrowDirectionRight
Animated:YES]
}
}
22. The meaning of various key values of plist
Original: http://www.minroad.com/?p=434
UIRequiresPersistentWiFi pops up the key selected by wifi in the program (wifi prompt needs to be turned on in system setup)
UIAppFonts embedded fonts (https://cache.yisu.com/upload/information/20200311/45/197695.jpg (renamed only)
Whether there are highlights on the UIPrerenderedIcon icon
Features required by UIRequiredDeviceCapabilities devices (click here for details)
The UIStatusBarHidden status bar is hidden (the difference from within the program is that it shows that Default.png is already in effect)
UIStatusBarStyle status bar type
Whether anti-aliasing is enabled for UIViewEdgeAntialiasing
CFBundleDisplayName app display name
CFBundleIconFile, CFBundleIconFiles icon
The difference between CFBundleName and CFBundleDisplayName is that this is a short name, within 16 characters.
CFBundleVersion version
CFBundleURLTypes custom url for leveraging the url rebound program
Localized language for CFBundleLocalizations local resources, used to display local discourses in the lower left corner of the itunes page
CFBundleDevelopmentRegion is also related to localization. If the user's location does not have the corresponding language resources, the value of this key will be used as the default.
Finally, official documents are attached. All key are available. The right way is to read the original English version:) I will enter.
24. Add multiple Target in xcode project
Transferred from: http://blog.sina.com.cn/s/blog_682dc7810100pv8t.html
What do you mean by multi-Targets? what's the use?
I believe many people have noticed that in XCode
There is a concept of Target.
This is reflected in many places.
For example, after opening a project, there is a Targets item in the list on the left, and in the top menu of the project interface.
There are also several projects involving Target in project.
So what exactly is this Target?
Here's what Apple's people say:
Quote
Targets that define the products to build. A
Target organizes the files and instructions needed to build a
Product into a sequence of build actions that can be taken.
Words of simple understanding
One target can be thought of as corresponding to a new product (based on the same code). But it's all in the same code, so what's a new product for?
Is it fun to mess with this?
Actually, it's not just messing around.
Although the code is the same, the compilation settings (such as compilation conditions) and the included resource files can vary greatly. So even if the same code
The output of product may also be very different.
Let's cite some typical cases of multi-Targets applications.
For example, the full version and the lite version; compare with the 20, 30 and 50 versions of a game; or sell it as a new game with some resources and names like a game.
What are you teaching?
What is the same and what is the difference between Targets!
Since the same code is used to produce different product
So what are the differences between different Target?
To explain this problem.
We're going to take a look at what a Target specifies.
From the list on the left side of XCode
We can see that a Target contains Copy Bundle Resources, Compile Sources, and Link
Binary With Libraries. Among them
Copy
Bundle Resources refers to which resource files will be contained in the .app of the generated product
Compile
Sources refers to what source code will be compiled
Link
Binary With Libraries refers to which library files will be referenced during compilation.
Through Copy
According to the different settings of the content in Bundle Resources, we can make different product contain different resources, including the main icon of the program.
Instead of including all the resources listed in XCode's project.
And this is not all the content specified by a target.
Each target can use a separate
Different Info.plist files.
We all know,
Many key elements of an iPhone project are defined in this Info.plist file, such as the program name
Finally generate the globally unique id of product, and so on.
And different target can also define complete and differentiated compilation settings.
From simply adjusting optimization options to adding compilation conditions used in conditional compilation, so that the base SDK used can be differentiated.
Create a second Target!
Why the second one?
Because the first one is to create the default Target after the project. (so much nonsense, drag it away.)
There are several ways to create a target
We can make a copy of the existing target and modify it slightly, or we can completely create a new target. But to put it bluntly,
The two methods are more or less the same
First of all, let's take a look at creating a target using replication.
Using replication to create target
We are in the list on the left side of XCode
Expand the Targets item, and on the existing target, right-select "Duplicate", or select the existing target
You can also choose "Duplicate" in the Edit on the top menu.
And then we get a new target.
And you will get a xxxx copy.plist in Resource. The new target is exactly the same as the original target.
The rest are just some differentiated changes, which we'll talk about later.
Create a brand new target
A method similar to replication
We can press the right-click menu in many places in the list on the left, and we can see that there will be "New Target..." in Add. An item
You can also see this "New Target..." in the Project on the top menu of the project. The figure.
After clicking
First of all, I will let you choose the type of target, since I have been referring to the program itself, then the natural choice of Application (as for the rest
If you are interested, do your own research, for example, we can extract parts of the program into a Static Library).
After Next
It will let you enter a new Target name, unlike the copy method, which generates a target name such as xxxxx copy by default.
But the Target generated in this way is almost empty.
Copy Bundle Resources, Compile Sources, Link Binary With
There is nothing in Libraries. The compilation settings are also completely primitive.
You can drag and drop content into these target settings
And adjust the compilation options to complete the configuration of Target.
The method of modifying part of the content in Target!
In fact, part of this paragraph
It may also be used in non-multi-Targets projects.
Because the modifications are basically done in the project / compilation settings.
Therefore, if there is no special case, it is no longer declared. To open the project / compilation settings corresponding to target, you can right-click on the target and select get.
Info to do it.
Modification of the generated product name:
Product Name item in the Packing paragraph
Info.plist file name:
The Info.plist File item in the Packing section, for example, the copied target thinks that the xxxxx
If copy.plist is stupid, you can change it here.
Strip
Component compilation: add a User-Defined Setting (Target "xxxx"
You can see this in the gear in the lower left corner of the build page of Info), and fill in the Other C Flag
For example, to define a definite value called LITE_VERSION, we can write "- DLITE_VERSION" or
"- DLITE_VERSION=1" Then it can be used in the program.
# if
Defined (LITE_VERSION)
# else
# endif
Such conditional compilation partially differentiates the code.
Maybe some friends remember the code that I posted in the code area to detect the cracked version.
One of the detection methods is to see whether the info.plist is text or binary, so can we suggest a simulated cracked target
Directly generate info.plist of the text for testing?
Yes, of course,
In the packing section, there is an item called "Info.plist Output Encoding", and the default value is Binary
As long as we choose xml, then the info.plist in the generated product.app is directly text-styled.
In addition
Outward, to Copy Bundle Resources, Compile Sources, Link Binary With
Add / remove files within Libraries. You can select get info on the file you want to change and switch to the Target page
Just check the target that you want to reference this file. For example, icon.png can be assigned to the default target and icon_lite.png can be assigned to lite
Target of verion
That's about it. I'm too lazy to take pictures. Make do with it, everyone. If you think of anything you need to add, I will join.
In addition,
An English course: http://www.codza.com/free-iphone-app-version-from-the-same-xcode-project
25. Explain the IOS SDK compatibility guide in detail
Transferred from: http://mobile.51cto.com/iphone-284052.htm
IOS SDK compatibility bootstrap is the content of this article, which is mainly based on the introduction of IOS SDK-based development to explain how to apply to the IOS SDK-based development technology of XCode project. Let's take a look at the details.
1. Use (weakly linked) weakly linked classes, methods, and functions to support programs running between different versions
2. Weakly link the whole framework (framework)
3. Choose different compilation conditions for different IOS SDK.
4. Find out the use of outdated API in the code
5. Determine the version of the operating system and framework (framework) at run time
Using weak join classes in IOS
When using weak joins of classes in a project, you must ensure the availability of these classes at run time, so as not to cause dynamic connection errors.
In later versions of IOS4.2, NSObject class's method is used to detect the availability of weak connections at run time. This simple and efficient mechanism uses NS_CLASS_AVAILABLE 's availability macros.
Check that the recent framework of release does not support macros of NS_CLASS_AVAILABLE
In conditional compilation of macro frameworks that support NS_CLASS_AVAILABLE, you can use the following
If ([UIPrintInteractionController class]) {
/ / Create an instance of the class and use it.
} else {
/ / Alternate code path to follow when the
/ / class is not available.
}
If you are not sure whether you are ready to use class methods, you can use the NSClassFromString method to determine, using the following methods:
Class cls = NSClassFromString (@ "NSRegularExpression")
If (cls) {
/ / Create an instance of the class and use it.
} else {
/ / Alternate code path to follow when the
/ / class is not available.
}
Second, use weak connections in methods, functions and symbols
As with weak joins of classes, make sure that method functions and symbols are available at run time before using it, or you will report a dynamic connection error at compile time, assuming you want to use the new version of IOS
SDK features but want to be able to run in a lower version of SDK, then you need to set the corresponding development target for the earlier version, in Object-c
InstancesRespondToSelector:
Method tells us whether the given method is available, for example, using availableCaptureModesForCameraDevice: this method (not available until 4. 0)
We can use it like this.
1. Check the availability of an Object-c method
If ([UIImagePickerController instancesRespondToSelector:
@ selector (availableCaptureModesForCameraDevice:)]) {
/ / Method is available for use.
/ / Your code can check if video capture is available and
/ / if it is, offer that option.
} else {
/ / Method is not available.
/ / Alternate code to use only still p_w_picpath capture.
}
To determine whether a weakly linked C function is available, as long as you determine whether the address of the function returns NULL, take the CGColorCreateGenericCMYK function as an example, we can use it as follows.
2. Check the availability of method C
If (CGColorCreateGenericCMYK! = NULL) {
CGColorCreateGenericCMYK (0.1, 0.5.0.0, 1.0, 0.10)
} else {
/ / Function is not available.
/ / Alternate code to create a color object with earlier technology
}
To test whether a C method is available, it is more specific whether the address is NULL or zero. You cannot use the inverse operator (!) To negate the availability of a function
To detect an external (extern) constant or the name of a notification, you should compare its address (address)-not the name of the symbol-to determine whether it is NULL or nil.
Third, weakly connect the whole Framework
For example, a Framework that appeared only in the higher version wanted to use its features in the lower version. Then you have to weakly connect to the Framework you are using, as detailed in the official diagram-(in fact, the required of the added Framework is changed to optional)
Http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/XcodeProjectManagement/
130-Files_in_Projects/project_files.html#//apple_ref/doc/uid/TP40002666-SW4
4. Conditional compilation of SDK with different for
If you compile based on more than one IOS SDK, you may need to do it for base
Sdk uses conditionalization, and you can use the definition in Availability.h. The .h file exists in the folder / usr/include of the system, for example, if you want to
The function CGColorCreateGenericCMYK is used in Mac OS X v10.5 instead of IOS
Conditional compilation using the preprocessing directive for
# ifdef _ _ MAC_OS_X_VERSION_MAX_ALLOWED
/ / code only compiled when targeting Mac OS X and not iOS
/ / note use of 1050 instead of _ _ MAC_10_5
# if _ _ MAC_OS_X_VERSION_MAX_ALLOWED > = 1050
If (CGColorCreateGenericCMYK! = NULL) {
CGColorCreateGenericCMYK (0.1, 0.5.0.0, 1.0, 0.10)
} else {
# endif
/ / code to create a color object with earlier technology
# if _ _ MAC_OS_X_VERSION_MAX_ALLOWED > = 1050
}
# endif
# endif
}
Find out the outdated examples used in the program
In IOS or Mac
Sometimes API is out of date in OS, but being out of date does not mean that those are deleted from Library or framework, but warning is reported during use, and not far away.
It may be removed by Apple in the future. For example, if we used the outdated function HPurge in code, we would report the following
'HPurge' is deprecated (declared at / Users/steve/MyProject/main.c:51)
So we should find the following warning in the project and modify it.
Determine the version of the operating system and Framework
Check the version of IOS at run time
NSString * osVersion = [[UIDevice currentDevice] systemVersion]
Check Gestalt function and system version constants for Mac OS X at run time
In addition, for many Framework you can check the version of the specified Framework at run time.
For example: Application Kit (NSApplication.h) defines the NSAppKitVersionNumber constant-can be used to check the version of Application Kit Framework.
Such as
APPKIT_EXTERN double NSAppKitVersionNumber
# define NSAppKitVersionNumber10_0 577
# define NSAppKitVersionNumber10_1 620
# define NSAppKitVersionNumber10_2 663
# define NSAppKitVersionNumber10_2_3 663.6
# define NSAppKitVersionNumber10_3 743
# define NSAppKitVersionNumber10_3_2 743.14
# define NSAppKitVersionNumber10_3_3 743.2
# define NSAppKitVersionNumber10_3_5 743.24
# define NSAppKitVersionNumber10_3_7 743.33
# define NSAppKitVersionNumber10_3_9 743.36
# define NSAppKitVersionNumber10_4 824
# define NSAppKitVersionNumber10_4_1 824.1
# define NSAppKitVersionNumber10_4_3 824.23
# define NSAppKitVersionNumber10_4_4 824.33
# define NSAppKitVersionNumber10_4_7 824.41
# define NSAppKitVersionNumber10_5 949
# define NSAppKitVersionNumber10_5_2 949.27
# define NSAppKitVersionNumber10_5_3 949.33
So we can use it like this:
If (floor (NSAppKitVersionNumber))
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.